JS: Arrays
Learn Arrays in JS with practical examples.
JS — Arrays
Overview
Arrays store ordered lists of values.
What you'll learn
- push/pop
- map/filter
- find
- spread
Syntax
const a = [1,2,3];
Example
const nums = [1,2,3,4];
const doubled = nums.map(n=>n*2);
const even = nums.filter(n=>n%2===0);
console.log(doubled, even);
Notes
- Prefer map/filter for transformations.
- Use find for single match.
Try: Open the Playground: /en/playground/html