JS: Array.of

By Xah Lee. Date: .

New in ES2015.

Array.of ( …items )

Return a new array with elements of …items.

console.log( Array.of(3)) // [3]
console.log( Array.of(3,4)) // [3, 4]
console.log( Array.of(3,4, 'x')) // [3, 4, 'x']

Array.of is provided to replace the complex behavior of array constructor.

〔►see JS: Array Constructor


ECMAScript® 2016 Language Specification#sec-array.of

Array Topic

  1. JS: Array Basics
  2. JS: Understand JS Array
  3. JS: Create Array
  4. JS: Sparse Array
  5. JS: Array-Like Object
  6. JS: Array How-To

  1. JS: Array Object
  2. JS: Array.prototype
Like what you read? Buy JavaScript in Depth