liveBook · Manning

Array

As explained in Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond

A built-in JavaScript ordered, indexable collection type whose constructor can create arrays of specified length or elements.

An array is an ordered, indexable collection for holding data. JavaScript provides methods to construct arrays and to search their contents. section 9.0

Common array methods support two tasks:

  • Construct arrays with Array.from, Array.of, or Array.prototype.fill. section 9.0
  • Search arrays with Array.prototype.includes or Array.prototype.find. section 9.0
$('.danger').css('color', 'red');

A DOM task makes the collection distinction concrete: select elements with the class danger and set their color to red. querySelectorAll returns a NodeList, not an Array. section 9.0 section 9.0

Arrays as generator input

A prisoner factory can receive an array of numbers recording previous sentence lengths. It uses those stats to adapt the prisoner it generates. section 19.1

How Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond covers it

How deep it goes
Names construction and search methods but does not detail their behavior in the available excerpts.
Examples
Uses a DOM color update and an array of previous prisoner sentence lengths as examples.
What you can do after
Apply Array.from, Array.of, fill, includes, and find to construct or search arrays.
How it connects
Connects arrays with DOM NodeLists, Array.from, Array.of, fill, includes, find, and generators.

Also explained in

Compare how 40 books explain array →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond. The section links point to the parts of the book it draws on.