Array.of method
The Array.of method returns
a new array from the values specified
in the parameter.
Syntax
let newArray = Array.of(element, [element, [element...]]);
Example
Let's obtain a new array from a number specified in the parameter:
let res = Array.of(1);
console.log(res);
The code execution result:
[1]
Example
Let's get a new array from strings specified in the parameter:
let res = Array.of('a', 'b', 'c');
console.log(res);
The code execution result:
['a', 'b', 'c']
See also
-
the
Array.frommethod
which obtains an array from an array-like object