Pure win: Array.from and Array.of

Mike Shaver mike.shaver at gmail.com
Sun Jul 10 03:27:31 PDT 2011


On Sun, Jul 10, 2011 at 6:06 AM, Dmitry A. Soshnikov
<dmitry.soshnikov at gmail.com> wrote:
> The problem:
>
> Array(4).map(function(x) x * x); // [NaN, NaN, NaN, NaN]

I think it actually produces just [ , , , , ], because map skips
holes.  (If you see the NaN behaviour in FF, please file a bug.)

If I hadn't made map skip holes, then the fill pattern would be simple enough:

Array(4).map(function (_,x) x * x);

Mike


More information about the es-discuss mailing list