- A callback is a function passed into another function. A higher-order function takes or returns functions.
forEachruns a function for each item. It can't be stopped early.maptransforms each item and returns a new array of the same length. Don't forgetreturnif you use curly braces!filterkeeps items whose callback returns truthy, and returns a new, possibly shorter array.findreturns the first matching item (orundefined).findIndexreturns its index (or-1).somechecks if any item passes.everychecks if all items pass.reducecombines all items into one value, using an accumulator. Always provide a starting value.sort's comparison function returns negative (a first), positive (b first) or zero. Usea - bfor numbers andlocaleComparefor strings. Sort a copy to protect the original.- Chain methods together to build readable data pipelines.
Reading is step one
CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.