Destructuring Assignment to Extract Values

Hi,
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?

Thanks,
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:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.