EN
JavaScript - assign array values to multiple variables?
1
answers
0
points
Is the code below a valid code? Seems like for some browsers it works fine and for others it doesn't work at all.
My code:
// ONLINE-RUNNER:browser;
var array = [1, 2, 3];
var a, b, c;
[a, b, c] = array;
console.log(a); // 1
console.log(b); // 2
console.log(c); // 3
1 answer
0
points
This feature is called a destructuring assignment and has been added in ES6. This is the reason it may not work in some browsers.
See also
References
0 comments
Add comment