O'Reilly logo

The JavaScript PocketGuide by Lenny Burdette

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required