Destructuring Assignment to Extract Values

I was reading documentation @ Destructuring assignment - JavaScript | MDN on Destructuring Assignment to try and understand it better after the freeCodeCamp lesson on it.

My question is, when I was trying some of the Syntax shown from Mozilla to better understand, I get :

const [a, , b] = array;
VM100556:1 Uncaught ReferenceError: array is not defined
    at <anonymous>:1:18

I’m don’t see why it doesn’t work as that’s the example shown?

Shawn Wright

The syntax section is meant to show you the basic syntax for destructuring but it does not include working examples.

That is why you are getting errors of array is not defined because it’s not.

If you want that example to work, then you will need to replace array with an actual array or define array at the top somewhere and assign it an actual array.

1 Like

I see, makes since now.
Thanks @jwilkins.oboe for the info. :smiley: