JavaScript new Array()

Definition and Usage

new Array() The constructor is used to create an array object.

Example

Example 1

// Create an array
const cars = new Array(["Saab", "Volvo", "BMW"]);

Try It Yourself

Example 2

Create an empty array and add values:

// Create an array
const cars = new Array();
// Add values to the array
cars.push("Saab");
cars.push("Volvo");
cars.push("BMW");

Try It Yourself

Example 3

Without new Array() Methods to create an array:

// Create an array
const cars = ["Saab", "Volvo", "BMW"];

Try It Yourself

Syntax

new Array(iterable)

Parameter

Parameter Description
iterable Required. An iterable object containing values.

Return Value

Type Description
Array New Array Object

Browser Support

new Array() Is a feature of ECMAScript1 (JavaScript 1997).

It is supported in all browsers:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Supports Supports Supports Supports Supports Supports