11New Array Features, Typed Arrays

In this chapter, you'll learn about many new features of arrays in ES2015+, including new features for traditional arrays and the new typed arrays.

Before getting into the meat of the chapter, a brief note about terminology: There are a couple of words used to refer to the contents of arrays, the two most popular being “elements” and “entries.” Although “elements” is probably used slightly more often than “entries,” I use “entries” in this book to avoid confusion with DOM elements and because it's the name of the method on arrays, entries, that you use to get an iterator for the entries in the array. But you'll very often hear “elements” instead, including in most parts of the JavaScript specification. “Element” is also used in one place in the standard API for typed arrays.


ES2015 (primarily), ES2016, and ES2019 added a host of new array methods, both for creating arrays and for accessing and modifying their contents.



arrayObject = Array.of(value0[, value1[, … ]])

Array.of creates and returns an array containing the values you pass to it as discrete arguments. For instance:

const a = Array.of("one", "two", "three");
console.log(a); // ["one", "two", ...

Get JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.