What is an Array?
Ordered values in numbered positions.
const fruits = ["🍎", "🍌", "🍇"]
🍎
0🍌
1🍇
2Indexes
Access any value by its position number.
fruits[]
🍎
0🍌
1🍇
2Length
How many items are in the array.
A
0B
1C
2.length =3
Updating Values
Tap a slot to replace its value.
fruits[1] = "🥭"
🍎
0🍌
1🍇
2Memory
Variables don't contain arrays — they point to them.
const fruits = ["🍎", "🍌", "🍇"]
fruits
heap
🍎
0🍌
1🍇
2The variable holds a reference — a pointer to where the array lives in memory.
References
Two variables can point to the same array.
const a = ["🍎", "🍌"] const b = a
a
b
🍎
🍌
Copy vs Reference
Spread creates a new array. Assignment shares the same one.
const a = [1, 2, 3] const b = a // reference const c = [...a] // copy
ab
1
2
3
cindependent
1
2
3
Sparse Arrays
Arrays can have empty slots — holes with no value.
const arr = [1, , 3]
1
0empty
13
2.length = 3
arr[1] = undefined
Length Magic
Setting a distant index creates empty slots automatically.
const arr = [] arr[5] = "🚀"
[ ] empty
Explorer
Your sandbox — create, modify, copy, and reference.
myArr
heap
.length = 3🍎
0🍌
1🍇
2