当前位置:网站首页>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进制)

边栏推荐
- 实体转JSON时,值为null的字段的丢失问题
- JS foundation 6
- Solve the problem of reading package listsdonebuilding dependency treereading state informationdone
- Xshell and xftp tutorial
- 选择哪种编程语言,会吸引优秀的人才?
- 使用logrotate对宝塔的网站日志进行自动切割
- Debug debugging in katalon
- Training notice | special training notice on epidemic prevention and security prevention for overseas Chinese funded enterprises, institutions and personnel in 2022
- Get current system date
- Xshell和Xftp使用教程
猜你喜欢

功能真花哨,价格真便宜!长安全新SUV真实力到底怎样?
This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错

day34 js笔记 正则表达式 2021.09.29

远程登录sshd服务

AGCO AI frontier promotion (6.28)

人人都可以参与开源!龙蜥社区最不容错过的开发者活动来了

Oracle 日期格式化异常:无效数字

Thesis reading (59):keyword based diverse image retrieval with variable multiple instance graph

Metersphere implements UI automation elements that are not clickable (partially occluded)

Industry analysis - quick intercom, building intercom
随机推荐
JS基础3
Katalon framework tests web (XX) custom keywords and upload pop-up operations
setInterval、setTimeout和requestAnimationFrame
人人都可以参与开源!龙蜥社区最不容错过的开发者活动来了
Xshell和Xftp使用教程
培训通知|2022年境外中资企业机构及人员疫情防控和安全防范专题培训通知
GDB简介
Redis6 1: what problems can be solved by the introduction of NoSQL and redis?
JS基础8
mysql-. SQL file phishing Online
JS基础2
Training notice | special training notice on epidemic prevention and security prevention for overseas Chinese funded enterprises, institutions and personnel in 2022
Fancy features and cheap prices! What is the true strength of Changan's new SUV?
This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错
Does flink1.15 support MySQL views? I configured the view name at the table name to save, but the table could not be found. Think
Oracle 日期格式化异常:无效数字
拼接String集合中的字符串_基于Stream
js中this的默认指向及如何修改指向 2021.11.09
毕业季 新的开始
JS基础1-JS引入与运算符