0/8 done~72 min
1
Mental model: Arrays
Mental
~5 min
2
The 15 array exceptions
Exceptions
~18 min
3
Predict the output
Predict
~10 min
4
True or False
T/F
~6 min
5
Fill in the blank
Fill
~5 min
6
Fix the bug
Fix Bug
~8 min
7
Spot the bug
Spot Bug
~5 min
8
Put it together
Cement
~15 min
1 / 8Read~5 min
Mental model: Arrays
Build the right picture in your head before we practice.
sort() mutates the original array and uses lexicographic order by default β [10, 9, 2].sort() gives [10, 2, 9]. Always pass a comparator for numbers. map/filter/reduce return NEW arrays; forEach returns undefined.
JavaScript arrays are objects with integer keys. Methods divide into two families: mutating (sort, reverse, push, pop, splice, fill) and non-mutating (map, filter, reduce, slice, concat). sort() converts elements to strings before comparing, which makes [10,9,2].sort() give [10,2,9]. Array(3) creates a sparse array with holes, not [undefined, undefined, undefined].
Scroll to the bottom to continue
Notes
π
Loadingβ¦
Sections
0/8 done~72 min
1
Mental model: Arrays
Mental
~5 min
2
The 15 array exceptions
Exceptions
~18 min
3
Predict the output
Predict
~10 min
4
True or False
T/F
~6 min
5
Fill in the blank
Fill
~5 min
6
Fix the bug
Fix Bug
~8 min
7
Spot the bug
Spot Bug
~5 min
8
Put it together
Cement
~15 min
Notes
Notes
π
Loadingβ¦