For a project a developer sent us a .js file with code similar to this:
var myList = [1,2,3]; var a,b,c; [a,b,c] = myList;
It works in Opera 10.30, Firefox 3.6.x but it's not ok for Opera 10.60 and Chrome.
It's just curiosity, do you have any reference or link that says this code is compliant to JS/ECMA standard or not?
What do you think?
So you can do:
let a, b; [a, b] = ["Hello", "World"]; console.log(a); // "Hello" console.log(b); // "World"
Or simply in one line if you're defining the variables:
let [a, b] = ["Hello", "World"]; console.log(a); // "Hello" console.log(b); // "World"
©2020 All rights reserved.