js中Math函数的用法——全
七娃博客173 次
let a1 = Math.abs(-15) //取绝对值 abs 15 let a2 = Math.ceil(15.6) //向上取整 ceil 16 let a3 = Math.floor(15.6) //向下取整 floor 15 let a4 = Math.round(15.6) //四舍五入 round 16 let a5 = Math.sqrt(16) //平方根 sqrt 4 let a6 = Math.pow(2,10) //n的m次方 pow(n,m) 1024 let a7 = Math.max(2,10,6) //取最大值 max 10 let a8 = Math.min(2,10,6) //取最小值 min 2 let a9 = Math.PI //取圆周率 PI 3.1415926 let a10 = Math.random() //0到1之间随机小数 random let a11 = Math.round(Math.random()*(10-2)+2) //n到m随机正整数 Math.round(Math.random()*(m-n)+n) console.log(typeof Math) // object
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。
转载请注明来源:js中Math函数的用法——全 - Qui-Note
评论 | 0 条评论