JavaScript: 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 JavaScript: Array Constructor

Reference

ECMAScript® 2016 Language Specification#sec-array.of

Array Topic

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

  1. JavaScript: Array Object
  2. JavaScript: Array.prototype
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.