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

10. Arrays

Engin Arslan1 
(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 = []; ...

Get Learn JavaScript with p5.js: Coding for Visual Learners 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.