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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.