Array.of()
The Array.of() and typed array .of() static methods create new arrays from the values of any number of arguments.
Overview
The Array.of() and typed array .of() static methods create new arrays from the values of any number of arguments.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 45 | 12 | 25 | 9 | 39 | 9 | |
| Built-in object | ||||||
| The TypedArray.of() static method creates a new typed array from a variable number of arguments. This method is nearly the same as Array.of(). | 45 | 12 | 38 | 10 | 45 | 10 |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Syntax
JAVASCRIPT
Array.of(1, 2, 3); // [1, 2, 3]
Array.of(3); // [3] (new Array(3) is an empty array of length 3)
Array.of(undefined); // [undefined] Live demo
generate with dynamic argument.
Undefined or null includeargument in also positivearrayization..
PreviewFullscreen
Use cases
Using Array.of()
The Array.of() and typed array .of() static methods create new arrays from the values of any number of arguments.
Cautions
- No specific concerns. Stable across all major browsers.
Accessibility
- When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.
Related links
Powered by web-features