🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## 1. js的内置对象 > 对象有 Array , object , Function , Data , Math ,Error , regpx ### 1.1 Math ``` /* Math.ceil 上取整 Math.floor 下取整 Math.round 四舍五入取整 Math.random() 0<=randow<1; */ console.log(Math.ceil(3.4)); console.log(Math.floor(3.4)); console.log(Math.round(3.4)); console.log(Math.random()); console.log(Math.max(1,2,3)) ``` ### 1.2 Date 时间 ``` var oDate = new Date(); var year = oDate.getFullYear(); var month = oDate.getMonth()+1; var date = oDate.getDate(); var hour = oDate.getHours(); var minute = oDate.getMinutes(); var second =oDate.getSeconds(); var min = oDate.getMilliseconds(); var day = oDate.getDay(); ``` ## 2. 解构赋值 ``` var arr = [1,2,3] //es6的解构赋值 左右要相同 var [a,b,c]=arr; console.log(a); console.log(c); //对象 var [a,b,c]=arr; var obj = { name:"ding", age:20 } var {name ,age}= obj; console.log(name); console.log(age); ```