Pure win: Array.from and Array.of

Mike Shaver mike.shaver at gmail.com
Sun Jul 10 04:14:11 PDT 2011


On Sun, Jul 10, 2011 at 7:09 AM, Dmitry A. Soshnikov
<dmitry.soshnikov at gmail.com> wrote:
>> If I hadn't made map skip holes, then the fill pattern would be simple
>> enough:
>>
>> Array(4).map(function (_,x) x * x);
>>
>
> It's in particular case, you try to multiply indices, which in current
> implementation of `map` anyway gives unfortunately nothing.

Yes, as I said it *would* work if map had been specified not to skip holes:

js> [undefined,undefined,undefined,undefined].map(function(_,x)x*x)
[0, 1, 4, 9]

Is that not what you want?

Mike


More information about the es-discuss mailing list