for-of statement of sparse array

Tab Atkins Jr. jackalmage at gmail.com
Mon Jul 9 09:02:01 PDT 2012


On Fri, Jul 6, 2012 at 3:35 AM, Jussi Kalliokoski
<jussi.kalliokoski at gmail.com> wrote:
> 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)
> }

If you're hiding it behind a function abstraction, there's absolutely
no need to carry over that obtuse functional paradigm.  Just put a
for-loop in that function and be efficient.

~TJ


More information about the es-discuss mailing list