O'Reilly logo

Learn JavaScript with p5.js: Coding for Visual Learners by Engin Arslan

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

© Engin Arslan 2018
Engin ArslanLearn JavaScript with p5.jshttps://doi.org/10.1007/978-1-4842-3426-6_10

10. Arrays

Engin Arslan
(1)
Toronto, Ontario, Canada
 
Arrays are another useful data structure in JavaScript. They are a sequential collection of data stored with a numbered index and are based on Objects, which make certain operations much easier to perform.
In this chapter we’ll populate an array using the push method. We’ll also learn about the remainder operator, which we can use to derive sequential values that cycle in between zero and the desired value.

Using the push Method

Remember that we use curly brackets to create an empty object. We can create an empty array in a similar fashion by using square brackets (Listing 10-1).
var arr = []; ...

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