Lesson content
Read, practise, then check your understanding
Arrays are resizable indexed objects. They can hold mixed values, though consistent element shapes make code safer and engines easier to optimize.
Declarative operations
const scores = [72, 84, 91, 68];
const passing = scores.filter(score => score >= 80);
const curved = scores.map(score => Math.min(100, score + 5));
const total = scores.reduce((sum, score) => sum + score, 0);
find returns an element, findIndex its index, some/every test conditions, and includes checks membership. Mutators include push, pop, splice, sort, and reverse; modern toSorted, toReversed, and toSpliced return copies. Spread and slice are shallow. Multidimensional arrays are nested arrays and may be ragged. Avoid sparse arrays and supply numeric comparators to sort.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.