On 05.11.2011 21:04, Dmitry Soshnikov wrote:
On 05.11.2011 20:54, Allen Wirfs-Brock wrote:
On Nov 5, 2011, at 9:45 AM, Dmitry Soshnikov wrote:

On 05.11.2011 20:38, Allen Wirfs-Brock wrote:
In a similar vain, what is the value of r in:

let [z,y,...r] = {0:0, 1:1, 2:2, length: 3, 3:3,4:4};

should it be [2] or [2,3,4] (and if the latter how is that determined)?

It seems to me that [2] is the right answer,
How so? If `...n` is the range slice operator, it should be [2, 3, 4], no?
How do you define the range of "array-like elements" of an object. In all other places of the ES specification, the value of the "length" property is used to determine the upper bound of the elements and any "integer keyed" elements beyond the length are ignored by array operations and functions.



Oh! I missed that the `length` is 2! Then yes, it seems it should be [2]. Though, have to think on missed properties also.

Dmitry.

Let's see.

What is the result in case of:

let a = [0, 1, 2, 3, 4];
a.length = 6;

let [z, y, ...r] = a;

if `...r` depends on the `length` of `a`, then `r` is [2, 3, 4, undefined]; If not, then `r` just takes only existing values (as some array methods do, e.g. forEach or map), and it's [2, 3, 4]. In later case, the simple object semantics obeys this rule.

Dmitry.


_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to