Skip to Content
๐ŸŽฒ Welcome to RandBox - Powerful JavaScript Random Data Generation Library! Learn More

integer

// usage randBox.integer() randBox.integer({ min: -20, max: 20 })

9007199254740991 is 2^53 - 1 and is the largest number value in JavaScript

Return a random integer.

range: -9007199254740991 to 9007199254740991

See: Largest number in JavaScriptย 

randBox.integer(); => -1293235

Can optionally provide min and max.

randBox.integer({ min: -20, max: 20 }) => -7

These min and max are inclusive, so they are included in the range. This means

randBox.integer({ min: -2, max: 2 })

would return either -2, -1, 0, 1, or 2.

// Specific case -2 <= random number <= 2 // General case min <= random number <= max
Last updated on: