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

边栏推荐
- 毕业了
- JS基础1-JS引入与运算符
- 论文阅读 (59):Keyword-Based Diverse Image Retrieval with Variational Multiple Instance Graph
- Everyone can participate in open source! Here comes the most important developer activity in dragon lizard community
- 还在用 SimpleDateFormat 做时间格式化?小心项目崩掉!
- Zero foundation self-study SQL course | if function
- day39 原型鏈及頁面烟花效果 2021.10.13
- This Exception was thrown from a job compiled with Burst, which has limited exception support. report errors
- 近况
- 无法重新声明块范围变量
猜你喜欢

一套十万级TPS的IM综合消息系统的架构实践与思考

JS foundation 1-js introduction and operator

Get current system date

Katalon framework tests web (XX) custom keywords and upload pop-up operations

Word、PDF、TXT文件实现全文内容检索需要用什么方法?

静态库的制作和使用

Dataease installation upgrade

Docker modifies the user name and password of MySQL

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

论文阅读 (59):Keyword-Based Diverse Image Retrieval with Variational Multiple Instance Graph
随机推荐
Fancy features and cheap prices! What is the true strength of Changan's new SUV?
Makefile introduction
Xshell和Xftp使用教程
This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错
Compareto() and equals() methods of BigDecimal class
Day39 prototype chain and page Fireworks Effect 2021.10.13
windows 10下载安装mysql5.7
工作组环境下的内网渗透:一些基础打法
买股票在中金证券经理的开户二维码上开户安全吗?求大神赐教
Secretary of the Ukrainian national security and National Defense Commission: will carry out precision strikes against targets in Russia
day34 js笔记 正则表达式 2021.09.29
ThreadLocal的简单理解
Recommended practice sharing of Zhilian recruitment based on Nebula graph
【SemiDrive源码分析】【X9芯片启动流程】32 - DisPlay模块分析 - RTOS侧
ProCAST有限元铸造工艺模拟软件
2022中国信通院首届业务与应用安全发展论坛成功召开!
2022 开源软件安全状况报告:超41%的企业对开源安全没有足够的信心
Setinterval, setTimeout and requestanimationframe
Redis6 1: what problems can be solved by the introduction of NoSQL and redis?
Create ECS using API shortcut