1、math
<script>
var sum = 13.45
console.log(Math.ceil(sum))
console.log(Math.floor(sum))
console.log(Math.round(13.16)) //四舍五入取整
console.log(Math.max(4,5,6)) //取最大值
console.log(Math.min(4,5,6)) //取最小值
</script>
Math.max() 取最大值
Math.min() 取最小值
Math.ceil() 向上取整
Math.floor() 向下取整
Math.round() 四舍五入
Math.random() 随机数
<script>
var arr = [4,5,6];
// var max = arr[0];
// for(var i = 1;i<arr.length;i++){
// if(arr[i]>max){
// max = arr[i];
// }
// }
console.log(Math.max(...arr));
console.log(Math.min(...arr))
</script>
2、date
var d = new Date()
/* 年,月,日 */
var year = d.getFullYear()
var month = d.getMonth()+1 // 月份是从0开始的,要加1
var date = d.getDate()
/* 时,分,秒 */
var hour = d.getHours();
var minute = d.getMinutes();
var second = d.getSeconds();
var mills = d.getTime(); //毫秒 1s = 1000毫秒
console.log(d);
console.log(year);
console.log(month);
console.log(date);
console.log(hour);
console.log(minute);
console.log(second);
<script>
var date = new Date();
console.log(date)
var year = date.getFullYear();
console.log(year)
var month = date.getMonth()+1;
console.log(month)
var data = date.getDate();
console.log(data);
</script>