Lesson 11. Destructuring

After reading lesson 11, you will

  • Know how to destructure objects
  • Know how to destructure arrays
  • Know how to combine array and object destructuring
  • Understand what types can be destructured

JavaScript, like other programming languages, has data structures like objects and arrays that allow you to structure data into logical groups and treat them as a single piece of data. JavaScript has always supported the concept of structuring, which is a concise syntax for taking several pieces of data and arranging them into a data structure. But that’s only half of the story: JavaScript has always been missing the reverse, a syntax for taking an existing data structure and destructuring it back into the parts that make it up. ...

Get Get Programming with JavaScript Next now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.