JavaScript 2025 · Arrays

Create a range of numbers

Build an array of the numbers 0 to 4.

const range = Array.from({ length: 5 }, (_, i) => i);

Official JavaScript 2025 documentation

More arrays commands

All arrays commands · JavaScript 2025 cheatsheet

Was this page helpful?