Array iterator questions
waldron.rick at gmail.com
Sun Dec 2 12:39:36 PST 2012
On Sun, Dec 2, 2012 at 2:47 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:
> On Dec 1, 2012, at 8:14 AM, Jason Orendorff wrote:
> > 2. According to 18.104.22.168.2, the iterators produced by
> Array.prototype.keys and .items will expose the index values as strings.
> Why strings? Don't numbers make more sense?
> It does that because array index keys are exposed as strings everywhere
> There is no specific definition (that I can find) of the keys iterator for
> arrays in the wiki proposal. There is only the general @iter.keys function
> which is defined in terms of for-in and hence returns string property keys.
> However, I don't have any objection to return integer keys in this case.
Users will take this for granted and assume the index value is going to be
a number since map, forEach, filter, every, some and reduce all pass a
number as the index argument and for-loops increment a number.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss