Home  >  Article  >  Web Front-end  >  javascript Math.random() random number function_basic knowledge

javascript Math.random() random number function_basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:42:251393browse

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)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn