function foo( [a,b] ) {
console.log(a);
console.log(b);
}
foo( [12,34] );
Prints:
12
34
Also here:
var { a:x, b:y } = { a:7, b:8 };
console.log(x); // prints: 7
console.log(y); // prints: 8
Is this method of assignment valid? Will this method bring any problems?
Also using the same technique we can swap two variables:
var a = 1;
var b = 2;
[a,b] = [b,a];
I just wanted to know what problems will arise in future with this type of assignment? Where can I find the best reference relating to this type of assignments?