js内置对象
Date(时间对象)
定义方式:var date = new Date()
console.log(date.getTime()); 返回距离1970/1/1 毫秒值
console.log(date.getFullYear()); 返回4为数的年份
console.log(date.getMonth()); 返回月份,从0开始
console.log(date.getDate()); 返回当月的第几天
console.log(date.getHours()); 返回小时0-23
console.log(date.getMinutes()); 返回分钟0-59
console.log(date.getSeconds()); 返回秒0-59
console.log(data.getMilliseconds()); 返回毫秒(1s=1000ms)
Math(数学对象)
Math.random() 生成0-1的随机数,16位小数
Math.ceil() 向上取整
Math.floor() 向下取整
Math.max() 求最大值,不接收数组
Math.min() 求最小值,不接收数组
Math.round() 取整,四舍五入
Math.PI() 圆周率

浙公网安备 33010602011771号