27 lines
653 B
Markdown
27 lines
653 B
Markdown
---
|
|
title: Array of
|
|
---
|
|
## Array of
|
|
|
|
The Array.of() method creates a new Array instance with a variable number of arguments, regardless of number or type of the arguments.
|
|
|
|
Syntax:
|
|
|
|
```javascript
|
|
Array.of(element0[, element1[, ...[, elementN]]])
|
|
```
|
|
|
|
## Example
|
|
|
|
```javascript
|
|
Array.of(7); // [7] - creates an array with a single element
|
|
Array.of(1, 2, 3); // [1, 2, 3]
|
|
|
|
Array(7); // [ , , , , , , ] - creates an empty array with a length property of 7
|
|
Array(1, 2, 3); // [1, 2, 3]
|
|
```
|
|
|
|
#### More Information:
|
|
For more information visit [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
|
|
|