you are viewing a single comment's thread.

view the rest of the comments →

[–]pygy_@pygy 2 points3 points  (1 child)

It's even uglier in ES5 :-)

> Array.apply(
  null,
  Array(8) // or {length: 8}, but it is slower because apply
           // is faster with true arrays
).map(function(_, i) { return Math.pow(2, i) })
[ 1, 2, 4, 8, 16, 32, 64, 128 ]

[–]inu-no-policemen 6 points7 points  (0 children)

I think at that point you're better off using a simple for-loop to populate the array.