1 Star 0 Fork 0

math.most/js_study

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
014.2Math对象.js 825 Bytes
一键复制 编辑 原始数据 按行查看 历史
math.most 提交于 2021-09-21 15:29 +08:00 . 超级补充
/**
* 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] {}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mathmost/js_study.git
git@gitee.com:mathmost/js_study.git
mathmost
js_study
js_study
master

搜索帮助