Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript generates numbers in a specified range

Shulou Source: shulou.com Published: 2022-06-01 04:27:13 11月13日 Update

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!

Tags: Range number generation content article two between value will create interest in boy buddy year situation array way method more birthday Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Microsoft Apple NVidia