I am right now experimenting with the iterable destructuring expression, and i am wondering why a specific way does not work. Maybe you can help me on that.
For example that works:
var x, y, myIterable = [];
myIterable[Symbol.iterator] = function* () {
var count = 0;
while(count < 2){
yield count++;
}
};
var myArray = Array.from(myIterable);
console.log(([x,y] = myArray) === myArray);
//OUTPUT: true
But if i try it this way it returns false
, can you explain why?
var x, y, myIterable = [];
myIterable[Symbol.iterator] = function* () {
var count = 0;
while(count < 2){
yield count++;
}
};
var myArray = Array.from(myIterable);
[x, y] = myArray;
console.log([x,y] === myArray);
//OUTPUT: false