JavaScript Math.random()方法介绍

随机法 (Random Method)

The JavaScript Math.random() method is an excellent built-in method for producing random numbers. When Math.random() is executed, it returns a random number that can be anywhere between 0 and 1. The 0 is included and 1 is excluded.

JavaScript Math.random()方法是用于生成随机数的出色的内置方法。 执行Math.random() ,它将返回一个随机数,该随机数可以在0到1之间。包括0和不包括1。

生成介于0和1之间的随机浮点数 (Generating a random floating point number between 0 and 1)

The Math.random() method will return a floating point (decimal) number greater than or equal to 0 and less than (but never equal to) 1. In other words 0 <= x < 1. For example:

Math.random()方法将返回一个大于或等于0且小于(但从不等于)1的浮点数(十进制)。换句话说, 0 <= x < 1 。 例如:

console.log(Math.random());
// 0.7069207248635578

console.log(Math.random());
// 0.765046694794209

console.log(Math.random());
// 0.14069121642698246

(Of course, the numbers returned will be dif

你可能感兴趣的:(java,python,javascript,random,js,ViewUI)