DrSchool Learn coding, fast.
EN AR BN CS DE EL Search

JS: Arrays

Learn Arrays in JS with practical examples.

Read time: 1 min Words: 34
Open Playground → HTML My Progress

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