Array Methods
Array methods are helpers that change lists or build new lists.
Some edit the same array. Some return a fresh one.
Think of sorting toys, filtering toys, or lining them up.
push and pop
shift and unshift
includes and indexOf
map, filter, and find
join
push and pop
push adds at the end. pop removes from the end.
unshift and shift
unshift adds at the start. shift removes from the start.
includes and indexOf
includes asks if an item is there.
indexOf tells the seat number, or -1 if missing.
map
map builds a new array by changing each item.
filter and find
filter keeps items that pass a test.
find returns the first item that passes.
join
join glues array items into one string.
Tip: Ask yourself if a method changes the old array or returns a new one. That question prevents many bugs.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.