Name
Array: built-in support for arrays — ECMAScript v1: Object → Array
Constructor
new Array( )
new Array(size)
new Array(element0,
element1, ...,
elementn)
Arguments
-
size The desired number of elements in the array. The returned array has its
lengthfield set tosize.-
element0, ... elementn An argument list of two or more arbitrary values. When the
Array( )constructor is invoked with these arguments, the newly created array is initialized with the specified argument values as its elements and itslengthfield set to the number of arguments.
Returns
The newly created and initialized array. When Array( ) is invoked with no arguments,
the returned array is empty and has a length field of 0. When invoked with a
single numeric argument, the constructor returns an array with the
specified number of undefined elements. When invoked with any
other arguments, the constructor initializes the array with the
values specified by the arguments. When the Array( ) constructor is called as a
function, without the new
operator, it behaves exactly as it does when called with the
new operator.
Throws
-
RangeError When a single integer
sizeargument is passed to theArray( )constructor, aRangeErrorexception is thrown ifsizeis negative or is larger than 232−1.
Literal Syntax
ECMAScript v3 specifies an array literal syntax. You may also create and initialize an array by placing a comma-separated list of expressions within square brackets. The values of these expressions become the elements of the array. For ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access