array methods
Built-in functions on every array, such as map, filter and forEach, that run a callback for each element.
In more detail
map returns a new array of transformed values, filter keeps the elements for which the callback returns true, and forEach just runs the callback. Passing a type predicate to filter narrows the resulting array type. Array.isArray checks whether a value is an array at all.
Related terms
- callback — A function you pass to other code so it can call you back later, for example when an event happens or a timer fires.
- type predicate — A return type written param is Type, which tells the compiler that when the function returns true, the argument has that type.
- contextual typing — Type inference that flows from where a value is used, such as giving a callback's parameters the types the calling function expects.
Taught in
- Type Annotations, Type Inference And Contextual Typing — Production TypeScript
- void, undefined And null: Exact Optional Property Types — Production TypeScript
- Typeof Guards, Truthiness And Equality Narrowing — Production TypeScript
- Custom Type Predicates: Functions Returning is Type — Production TypeScript
- Union Utilities: Exclude, Extract, NonNullable And Awaited — Production TypeScript
- Conditional Types: Ternary Types And Type Inference With infer — Production TypeScript
- Mapped Types, Key Remapping With as And Template Literals — Production TypeScript
- The satisfies Operator: Safe Validation Without Widening — Production TypeScript