JavaScript-Math对象方法之random随机数
Math是JavaScript的一个对象方法,里面包含了许多数学方法,非常方便。Math.random()会生成一个0-1之间的随机小数。 以下方法是分别生成0-n以内的随机数 和x-y以内的随机数。求0-n 以内的随机数, 包括0和nMath.round(Math.random()*n) //0-10 console.log(Math.round(Math.random()...