DEV Community

Discussion on: 1 line of code: How to create a range array

Collapse
 
gaoryrt profile image
gaoryrt
const createRange = (from, to) => [...Array(to + 1).keys()].slice(from);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
martinkr profile image
Martin Krause

Hi,
thank you for your contribution.
Nice code - I'll set up a benchmark.

Cheers!

Collapse
 
martinkr profile image
Martin Krause

Check the Benchmark) if you like.