Playlist: p5.js Tutorial
Playlist: Array Functions in JavaScript (from Topics of JavaScript/ES6)
MDN Web Docs: Arrays describes the Array type, and documents and has examples for each of the Array methods.
The JS Cheat Sheet has a module on Arrays:
From the JS Cheat Sheet.
Sarah Drasner's JavaScript Array Explorer allows you to choose the operation, and see the code (the Array method) that does this.
Read
Insert
Remove
Replace
First Element
array[0]
array.unshift('a')
array.shift()
array[0] = 'A'
Middle
array.slice(2, 3)
array.splice(2, 0, 'c', 'd', 'e')
array.splice(2, 3)
array.splice(2, 3, 'C', 'D', 'E')
Last Element
array[array.length - 1]
array.push('z')
array.pop()
array[array.length-1] = 'Z'
shift()
and unshift()
), the middle (slice()
and splice()
), and the end (push()
and pop()
).JavaScript Iteration Methods compares array.map()
, array.forEach()
, array.some()
, and array.every()
to the same functionality written using for
loops.