Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of random method in javascript

Shulou Source: shulou.com Published: 2022-06-02 19:53:53 10月21日 Update

This article mainly introduces what is the use of random method in javascript. It is very detailed and has certain reference value. Friends who are interested must finish it!

The javascript random method is used to return a random number between 0 and 1, which uses syntax such as "Math.random ()", and the return value is a pseudo-random number between 0. 0 and 1. 0.

This article operating environment: windows7 system, javascript1.8.5 version, DELL G3 computer.

JavaScript random () method

Definition and usage

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

Grammar

Math.random ()

Return value

A pseudorandom number between 0.0 and 1.0.

Example

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

[xss_clean] (Math.random ())

Output:

0.8187371959444101 is all the content of this article "what is the use of random method in javascript". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Methods between random numbers content articles grammar values interests examples guys partners more environment computers knowledge systems industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Docker vpn Shulou Information