目录:
1. Math对象
属性、方法名 | 功能 |
---|---|
Math.PI | 圆周率 |
Math.floor() | 向下取整 |
Math.ceil() | 向上取整 |
Math.round() | 四舍五入版 就近取整 注意 -3.5 结果是 -3 |
Math.abs() | 绝对值 |
Math.max() | 最大值 |
Math.min() | 最小值 |
Math.random() | 获取范围在[0,1)内的随机值 |
2. Date对象 返回顶部
方法名 | 说明 | 代码 |
---|---|---|
new Date() | 实例化日期对象 | |
getFullYear() | 获取当年 | 声明的变量名.getFullYear() |
getMonth() | 获取当月(0-11) | 声明的变量名.getMonth() |
getDate() | 获取当天日期 | 声明的变量名.getDate() |
getDay() | 获取星期几(周日[0]到周六[6]) | 声明的变量名.getDay() |
getHours() | 获取当前小时 | 声明的变量名.getHours() |
getMinutes() | 获取当前分钟 | 声明的变量名.getMinutes() |
getSeconds() | 获取当前秒钟 | 声明的变量名.getSeconds() |