Arrays
1.1.1
Basic
MECHANICS
1
You know a lot already!
strings are just arrays of characters, so the overlap makes sense
Arrays are “mutable”
mutation !== reassignment
`const` doesn’t block mutations!
Destructuring is a really cool trick that’s used all the time
Advanced
MECHANICS
2
Advanced
Destructuring is a really cool trick that’s used all the time
nested data structures are common, but let’s start simple
for of loops are less flexible, but more compact
Copy vs
MUTATE
3
Making copies
The spread operator is a new but useful tool to JS
Changing === mutating
push, pop, unshift, and shift affect the front and back
splice() is how we interact with the middle of arrays
Mutations vs Copy
mutating an argument is a side effect
Pass By
REFERENCE
4
Arrays pass references
Accidentally mutating references is a common bug
A more complex example