Standard built-ins

Array.of()

Try the free JavaScript compiler

Creates an array containing the supplied arguments. A single numeric argument is an element, unlike the length form of the Array constructor.

Formal Syntax & Structure

javascript syntaxjavascript
Array.of(...items)

Parameters & Attributes

NameTypeDescription
itemsany[]Values placed at consecutive indices.

Return Value

Array

New array when called as Array.of.

Working Example

Example Snippetjavascript
console.log(Array.of(6).length,Array.of(6)[0]);
JavaScript Reference