Creates a new array with length elements. Element values are determined
by a function f of the element index. Returns null for invalid lengths
(non-integer or negative). createWith also treats a length greater than maxLength as
invalid, to prevent errors that could halt the interface, use excessive memory,
etc. If you truly intend to create a very long array, you may set maxLength
to a value higher than the default of 10000 to accommodate this need.
Remarks
Note that as an array creation function, createWith is one of the few
functions in this module that neither takes an array as an argument nor
returns such a function.
Creates a new array with
length
elements. Element values are determined by a functionf
of the element index. Returnsnull
for invalid lengths (non-integer or negative).createWith
also treats alength
greater thanmaxLength
as invalid, to prevent errors that could halt the interface, use excessive memory, etc. If you truly intend to create a very long array, you may setmaxLength
to a value higher than the default of 10000 to accommodate this need.Remarks
Note that as an array creation function,
createWith
is one of the few functions in this module that neither takes an array as an argument nor returns such a function.Example