Built-in objects

Array constructor

Try the free JavaScript compiler

Creates an array. A single Number argument denotes the array length and must be a valid length; multiple arguments become elements. Prefer literal syntax for a single numeric element.

Formal Syntax & Structure

javascript syntaxjavascript
Array(...items) or new Array(...items)

Parameters & Attributes

NameTypeDescription
itemsvalues or single lengthElements, or one numeric length.

Return Value

Array

New array.

Working Example

Example Snippetjavascript
console.log(Array(3).length, 0 in Array(3), [3][0]);
JavaScript Reference