Without further intro, I'll go straight to the point.
What is Array destructure?
As MDN describes it, destructuring is a way of unpacking values from, in our case, an Array (or properties from an Object, but we'll focus on the Array on this topic).
There are a lot times, when I want to access a value from an array, say the first value, and store it in a variable, this is what I normally do:
With array destructuring, I discovered that I can do that in just a single line of code.
This means that the first value of the array (which is pencil) will immediately be stored to a variable pencil. It could also be another variable name, and it'll still be of the same result:
Top comments (0)