当前位置:网站首页>day29 js笔记 2021.09.23
day29 js笔记 2021.09.23
2022-06-28 11:20:00 【即将成为大佬的小梦】
Math内置对象:
- Math.PI 圆周率
- Math.abs() 绝对值
- Math.max() 最大值
- Math.min() 最小值
- Math.ceil() 向上取整(天花板函数)
- Math.floor() 向下取整(地板函数)
- Math.round() 四舍五入
- Math.random() 随机数(0~1)

如果内置对象中的元素是字符串:
- 字符串的内容是数字的时候 会默认转换为数字类型
- 字符串的内容是中文汉字的时候 会返回NaN(not a number)
日期对象:Date函数 (GMT 标准时间 格林威治/格林尼治时间 1970-1-1 00:00:00)
创建方式:new Date()
获取时间:

拓展:将输出的结果显示在浏览器中: 结构.innerHTML = 输出结果
设置时间:

时间戳:将当前时间转换为毫秒数
1) 日期对象 . getTime()

2)在创建日期对象的new前面加一个 +

日期的格式化设置:
1.转换为年月日 toLocaleDateString()
2.转换成时分秒 toLocaleTimeString()
3.转换为年月日时分秒 toLocaleString()

进制间的转换:
tostring方法将十进制数字转为其他进制

parseInt方法将其他进制数字转为十进制(第二个参数值默认为10进制)

边栏推荐
- What is the function of ICMP Protocol and the principle of Ping of death attack?
- 《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作!
- Redis6 一:Nosql引入、Redis可以解决什么问题?
- SQL必需掌握的100个重要知识点:检索数据
- Training notice | special training notice on epidemic prevention and security prevention for overseas Chinese funded enterprises, institutions and personnel in 2022
- 2022 open source software security status report: over 41% of enterprises do not have enough confidence in open source security
- Zero foundation self-study SQL course | if function
- JS基础8
- 一套十万级TPS的IM综合消息系统的架构实践与思考
- day34 js笔记 正则表达式 2021.09.29
猜你喜欢

Everyone can participate in open source! Here comes the most important developer activity in dragon lizard community

阿里三面:LEFT JOIN关联表中用ON还是WHERE跟条件有什么区别

Debug debugging in katalon

培训通知|2022年境外中资企业机构及人员疫情防控和安全防范专题培训通知

太阳能无线LED显示屏的特点

day39 原型链及页面烟花效果 2021.10.13

Dataease installation upgrade

String & heap & method area

Wealth management for programmers

人人都可以参与开源!龙蜥社区最不容错过的开发者活动来了
随机推荐
ThreadLocal的简单理解
[monkey] Introduction to monkey test
New listing of operation light 3.0 - a sincere work of self subversion across the times!
Redis6 一:Nosql引入、Redis可以解决什么问题?
近况
Xshell and xftp tutorial
乌国家安全与国防委员会秘书:将对俄境内目标进行精确打击
day39 原型链及页面烟花效果 2021.10.13
100 important knowledge points that SQL must master: retrieving data
JS基础6
mysql-. SQL file phishing Online
JS基础5
JS基础8
MytipartFile与File的相互转换
Secretary of the Ukrainian national security and National Defense Commission: will carry out precision strikes against targets in Russia
JS基础2
数据库系列:有什么办法对数据库的业务表进行无缝升级
Blue Bridge Cup Maze (dfs+ backtracking)
董宇辉,新东方以及凤凰卫视
JS foundation 4