4. Arrays

Arrays are a great tool for organizing and manipulating a lot of data. JavaScript arrays can store any of the JavaScript data types in any order. If you store your data in arrays, operating on it is simply a matter of looping over each value. It’s a simple operation, but you’ll find that arrays and loops have endless uses in JavaScript programming.

Creating Arrays

The best way to create a new array is with the array literal syntax ([]), but the array constructor function is available too. If you pass a single number value to the constructor function, you get an array filled with that many undefined values.

image

Properties

Like strings, ...

Get The JavaScript PocketGuide now with O’Reilly online learning.

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