- Math.pow(value,n):value的n次方
- Math.pow(10,3);—>10的三次方–>1000
- Math.sqrt(value):把value值進行開平方
- Math.sqrt(100);—>10
- Math.abs():獲取絕對值
- 列表內容
- Math.ceil():向上取整
- Math.floor():向下取整
- Math.round():四捨五入(負數部分需要注意和正數不同)
- Math.max():獲取一堆數中的最大值
- Math.min():獲取一堆數中的最小值
Math.random():獲取[0~1)之間的隨機小數
**
獲取[n-m]之間的隨機整數
:Math.round(Math.random()*(m-n)+n)
-
獲取[1-10]之間的隨機整數
:Math.round(Math.random()*9+1)