Latest

recent

JavaScript random() Method

Definition and Usage

The random() method returns a random number between 0 and 1.

Syntax

Math.random()


Example

In this example we will get a random number between 0 and 1:

<script type="text/javascript">
document.write(Math.random());
</script>
 
The output of the code above can be:

0.29183834001354014
 
JavaScript random() Method Reviewed by 1000sourcecodes on 02:31 Rating: 5
Powered by Blogger.