代码拉取完成,页面将自动刷新
/**
* Math对象
* 不是一个构造函数,封装了数学运算的函数方法,不需要创建对象
*/
// 圆周率
console.log(Math.PI); // 3.141592653589793
// 绝对值
console.log(Math.abs(-1)); // 1
// ceil对数字进行上舍入
console.log(Math.ceil(123.45)); // 124
// floor对数字进行下舍入
console.log(Math.floor(123.45)); // 123
// max
console.log(Math.max(1, 9)); // 9
// min
console.log(Math.min(1, 9)); // 1
// pow返回x的y次幂
console.log(Math.pow(2, 3)); // 8
// random返回0-1的随机数
console.log(Math.random()); // 0.22954001641551036
// round把数四舍五入为最近的整数
console.log(Math.round(123.45)); // 123
// sqrt返回数的平方根
console.log(Math.sqrt(4)); // 2
// valueOf返回Math对象的原始值
console.log(Math.valueOf()); // Object [Math] {}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。