保存对代码的热爱,并保持怀疑态度
内置对象 - Math
- 数学对象,提供了一些数学操作
- Math.round() 大于5进1, -1.6=-2, 1.6=2
- Math.random() 0~1随机数,不包括0和1
- Math.abs() 绝对值
- Math.ceil() 向上取整 4.1=5
- Math.floor() 向下取整 4.1=4
- Math.max() 最大值 不能接收数组
- Math.min() 最小值 不能接收数组
- Math.pow() 第一个数字的第二个数字次方 (3,3) 3个3
- Math.sqrt() 开平方
- Math.sin() 正切 Math.sin(90 / (180 / Math.PI)
- Math.cos() 余切 Math.sin(90 / (180 / Math.PI)
- Math.PI π3.1415926…
随机数: Math.round(Math.random()*(max-min)+min)
Date 日期
获取:年月日周时分秒分秒毫秒
-.getFullYear() 年
- .getMonth() - 0~11 月
- .getDate() 日
- .getDay() - 0~6 星期几
- .getHours() 时
- .getMinutes() 分
- .getSeconds() 秒
- d.getMilliseconds() 毫秒