Note that as numbers in JavaScript are IEEE 754 floating point numbers with round-to-nearest-even behavior,
the ranges claimed for the functions below (excluding the one for Math.random() itself) aren't exact.
If extremely large bounds are chosen (2^53 or higher),
it's possible in extremely rare cases to calculate the usually-excluded upper bound.
Math.random() does not provide cryptographically secure random numbers.
Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the window.crypto.getRandomValues() method.
Note that as numbers in JavaScript are IEEE 754 floating point numbers with round-to-nearest-even behavior, the ranges claimed for the functions below (excluding the one for Math.random() itself) aren't exact. If extremely large bounds are chosen (2^53 or higher), it's possible in extremely rare cases to calculate the usually-excluded upper bound.
Math MDN
Note
Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the window.crypto.getRandomValues() method.
Returns
expected output: a number from 0 to <1