How JavaScript generates numbers in a specified range
This article mainly introduces JavaScript how to generate a specified range of numbers, the article is very detailed, has a certain reference value, interested friends must read it!
Generate a specified range of numbers
In some cases, we create an array between two numbers. Suppose we want to judge whether someone's birthday is in a certain range of years, then here is a very simple way to achieve it
Let start = 1900, end = 2000; [... new Array (end + 1). Keys ()] .slice (start); / / [1900, 1901,..., 2000] / / there is this way, but it is not stable for a very wide range of Array.from ({length: end-start + 1}, (_, I) = > start + I); these are all the contents of the article "how JavaScript generates numbers in a specified range". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!