An array destructing specification choice
Allen Wirfs-Brock
allen at wirfs-brock.com
Sat Nov 5 09:28:32 PDT 2011
In the following declaration, what should be the value of z?
let [z,y,z] = {0:0, 1:1, length: 2, 2:2};
should it be be 2 or undefined
undefined might be reasonable because it is an array pattern, and the source object is only has two "array-like" elements
2 might be reasonable because the source object actually has a property named "2"
Which alternative will be least surprising to JS programmers?
Allen
More information about the es-discuss
mailing list