JavaScript new Array()
- 上一页 []
- 下一页 at()
- 返回上一层 Manwal ng Sanggunian ng JavaScript Array
Definition and Usage
new Array()
Constructor used to create an array object.
Instance
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 using new Array()
Method 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 ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- 上一页 []
- 下一页 at()
- 返回上一层 Manwal ng Sanggunian ng JavaScript Array