Array Destructuring: Extracting and Ignoring Values

Get introduced to destructing and learn how array destructing is used to extract values.

Destructuring

Destructuring is an elegant way to extract data from arrays and objects. It removes the excessiveness and repetitiveness of using indexing operators or dots to get to the data within arrays and objects.

This notation takes a bit of getting used to, but soon you’ll be quite comfortable using it in your own code and also recognizing it in code you read.

Array destructuring

Functions typically return a single value: a primitive or an object. There is no elegant way to return multiple values other than returning an array. This makes the code within the function easy to write, but it turns the code on the receiving end messy.

Let’s take a look at an example. Here’s a function that returns an array.

Get hands-on with 1400+ tech skills courses.