当前位置:网站首页>js基础知识整理之 —— Math
js基础知识整理之 —— Math
2022-08-02 22:49:00 【猴小七儿】
Math
js为了方便开发者,进行数字的一些运算和处理,给提供了一个内置的Math对象,
在Math对象上,有些属性,属性值是对应的函数,这就组成了我们js中数学的运算方法,可以直接通过Math调用
1、Math.abs() 取数字的绝对值 (正数)
console.log(Math.abs(-3));//--->3
2、Math.ceil() 数字向上取整
3、Math.floor() 数字向下取整
4、Math.round() 获取数字进行四舍五入
5、Math.roandom() 获取0-1之间随机小数,包含0
Math.round(Math.random()*(90-60)+60);包括60和90
6、Math.round(Math.random()*(n-m)+m); 任意数之间取整数
边栏推荐
猜你喜欢

IDEA 重复代码的黄色波浪线取消设置

TDengine 在中天钢铁 GPS、 AIS 调度中的落地

PHP实现登录失败三次需要输入验证码需求

Shunted Self-Attention via Multi-Scale Token Aggregation

基于STM32的FLASH读写实验含代码(HAL库)

I have been in the software testing industry for nearly 20 years, let me talk to you about today's software testing

00 -- jieba分词

学习Autodock分子对接

Rebound shell principle and implementation

MySQL最大建议行数2000w, 靠谱吗?
随机推荐
严格反馈非线性系统基于事件触发的自抗扰预设有限时间跟踪控制
【代码扫描修复】MD5加密弱HASH漏洞
Week 7 - Distributional Representations
Matplotlib drawing core principles explain (more detailed)
同一份数据,Redis为什么要存两次?
脂溶性胆固醇-聚乙二醇-叠氮,Cholesterol-PEG-Azide,CLS-PEG-N3
PHP实现登录失败三次需要输入验证码需求
创建型模式 - 单例模式Singleton
程序员如何优雅地解决线上问题?
21天学习挑战赛(1)设备树的由来
redis的学习笔记
No-code development platform form styling steps introductory course
The latest real software test interview questions are shared. Are you afraid that you will not be able to enter the big factory after collecting them?
Apache Doris 1.1 特性揭秘:Flink 实时写入如何兼顾高吞吐和低延时
B站回应“HR 称核心用户都是 Loser”:该面试官去年底已被劝退,会吸取教训加强管理
Unity WallFxPack使用
vscode 自定义快捷键——设置eslint
分库分表索引设计:二级索引、全局索引的最佳设计实践
MySQL最大建议行数2000w, 靠谱吗?
airflow db init 报错