JS 之 Math.random() 隨機數生成數

Math.random()——使用Math.random() 會返回0~1 (包含0,不包含1)任意隨機數。 如: 打印結果: 使用案例: 當我們要取隨機數爲1、2、 3時,可以通過 parselnt(Math.random()*3+1) 來實現 parselnt(Math.random)*3+1) 解析: Math.random()*3+1一>取到 最小爲1,最大爲3的整數(小數加1都會大於1,
相關文章
相關標籤/搜索