undefined being treated as a missing optional argument

Brandon Benvie brandon at brandonbenvie.com
Thu Apr 12 09:23:16 PDT 2012


This is also a shortcut to making a dense array of a given size.

Array.apply(null, Array(5)) // [undefined, undefined, undefined, undefined,
undefined]

Array(5).map(...) // won't do anything with a sparse array
Array.apply(null, Array(5)).map(Function.prototype.call.bind(Number)) //
[0,1,2,3,4,5]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120412/1dba5f36/attachment.html>


More information about the es-discuss mailing list