Categories
JavaScript Answers

How to generate a range within the supplied bounds with JavaScript?

Spread the love

To generate a range within the supplied bounds with JavaScript, we use the array keys method.

For instance, we write

const a = Array.from(Array(10).keys());

to call Array(10).keys() to get an array of indexes of the array with length 10.

Then we use Array.from to create a copy of the array and return it.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *