Chapter 8 of 16All chapters
Chapter 8 of 16
Arrays
Ordered lists and the methods that build new ones.
Build new, or change in place
map, filter and reduce return something new and leave the original alone. push, splice, sort and reverse change the array where it stands, so copy first when that matters.
- map always returns an array the same length as the input.
- forEach returns undefined and exists only for its side effects.
Finding things
find returns the first matching item and findIndex its position, while includes and some answer yes or no. All of them stop as soon as they have an answer.