JavaScript new Array()
- Previous Page []
- Next Page at()
- Go to the Previous Level JavaScript Array Reference Manual
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"]);
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");
Example 3
Without new Array()
Methods to create an array:
// Create an array const cars = ["Saab", "Volvo", "BMW"];
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 |
- Previous Page []
- Next Page at()
- Go to the Previous Level JavaScript Array Reference Manual