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

javascript Math.random() random number function_basic knowledge

WBOY
Release: 2016-05-16 18:42:25
Original
1413 people have browsed it

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)

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template