JavaScript Array.of()
Examples
Create a new array from a number of arguments:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop();
Try it Yourself »
Description
The Array.of()
method creates a new array from any number of arguments.
The Array.of()
method can take any type of arguments.
Syntax
Array.of(element1, element2, ... , elementN)
Parameters
Parameter | Description |
elements | Optional. Any number of elements regardles of type. |
Return Value
Type | Description |
An Array |
A new array created from the arguments. The arguments can be strings, numbers, arrays, or any other allowed type. |
Related Pages:
Browser Support
of()
is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported in all modern browsers since June 2017:
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |
of()
is not supported in Internet Explorer.
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.