1-5-2-js-核心语法-常用的内置对象:math对象

math对象

var n = -5;
n2 = Math.abs(n); //绝对值
console.log(n2);
Math.floor(5.9); //直接往下去,这就是5,
Math.min(1,2);
Math.max(1,2);
Math.pow(10,2); //返回x的y次幂
Math.random(); //返回一个0-1之间的随机数
Math.round(5.5); //四舍五入

posted @ 2023-04-06 09:12  技术改变命运Andy  阅读(6)  评论(0编辑  收藏  举报