Array iterator questions

Rick Waldron 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:
>


> snip
>


> > 2. According to 15.4.6.2.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
> else.
>
> 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.
>

+1

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.

Rick


>
> Allen
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121202/99f1433f/attachment.html>


More information about the es-discuss mailing list