for-of statement of sparse array

Jussi Kalliokoski jussi.kalliokoski at gmail.com
Fri Jul 6 03:35:47 PDT 2012


Hahah, sweet, but it doesn't make it faster to type needed at all! Quite
the opposite even, it requires more thinking. ;)

But maybe I'll just add yet another function to my boilerplate:

function createArray (l, cb) {
    return Array.apply(null, new Array(l))
        .map(Function.call.bind(Number))
        .map(cb)
}

Cheers,
Jussi

On Fri, Jul 6, 2012 at 10:59 AM, Brandon Benvie
<brandon at brandonbenvie.com>wrote:

> Hey look, it's my favorite example.
>
> var powersOf2 = Array.apply(null, new
> Array(32)).map(Function.prototype.call.bind(Number)).map(Math.pow.bind(null,
> 2))
>
>  > var powersOf2 = []
>> >
>> > for (var index=0; index<16; index++) {
>> >   powersOf2.push(Math.pow(2, index))
>> > }
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120706/f42997dc/attachment.html>


More information about the es-discuss mailing list