var x = [a, b, ...[c, d]]
implies assumption that global Array.prototype[Symbol.iterator] has no side effects
arrays can be in-lined even if there are accessors as there is no behavior change
var x = {
get b() { console.log('called b!'); return 2; },
get c() { console.log('called c!'); return 3; }
};
console.log([1, x.b, ...[x.c, 4]]);
sparse arrays
elision in array spread is evaluated to undefined, this changes behavior of map and forEach
console.log([...[1, , 3]]) // [ 1, undefined, 3 ]
console.log([1, , 3]) // [ 1, <1 empty slot>, 3 ]
implies assumption that global
Array.prototype[Symbol.iterator]has no side effectsarrays can be in-lined even if there are accessors as there is no behavior change
sparse arrays
elision in array spread is evaluated to undefined, this changes behavior of
mapandforEach