Home >Web Front-end >JS Tutorial >javascript Math.random() random number function_basic knowledge
random function syntax
Math.random();
random function parameters
No parameters
random function return value
Returns a pseudo-random number between 0 and 1, possibly 0 , but always less than 1, [0,1)
random function example
document.write(Math.random());
Return a random number
document.write (Math.random()*(20-10) 10);
Returns a random number from 10-20
document.write(Math.random()*(n-m) m);
The formula that returns a random number in the specified range (between m-n)