本文轉載於:猿2048網站Math對象經常使用方法javascript
var num = 10; console.log(Math.pow(num, 3)); //num的三次方
console.log(Math.round(0.45)); //只看小數後面哪一位。
console.log(Math.ceil(5.000000001)); //6
console.log(Math.floor(5.9999999)); // 5
var num = 100; console.log(Math.max(10,num, 20, -40));
var num = 100; console.log(Math.min(10,num, 20, -40));
console.log(Math.random()); //若是想要50-100就乘50+50(max-min)*Math.random() + min