Math.random 随机数方法

随机取数方法
Math.random()   表示0到1之间随机取一个数   0<x<1   小数
Math.random()*5  表示0<x<5
parseInt(Math.random()*5)     0  1  2  3  4   中随机取一个数

公式:表示0到n 的随机取数(整数)
parseInt(Math.random()*(n+1)) 
原文地址:https://www.cnblogs.com/Model-Zachary/p/7048095.html