Destructuring

Dealing with objects and arrays has never been easier! Learn how to use destructuring to improve your code.

MDN defines destructuring like this:

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

Let’s start with destructuring objects first.

 

Destructuring Objects #

To create variables from an object, we used to do the following:

Get hands-on with 1200+ tech skills courses.