javascript回顧(五)日付配列オブジェクトapi


Date.now()//         
var dt=new Date()
dt.getTime()//     
dt.getFullYear()// 
dt.getMonth()//  0-11
dt.getDate()//   1-31
dt.getHours()//   0-23
dt.getMinutes()//   0-59
dt.getSeconds()// 0-59
//            
Math.random()
//   api

//forEach
var array=[1,2,3]
array.forEach((item,index) => {
    console.log(index,item)
});

//every             ,       
var array=[1,2,3,5]
var result=array.forEach((item,index) => {
    if(item<4){
        return true
    }
});
console.log(result)


//some             ,         
var array=[1,2,3,5]
var result=array.forEach((item,index) => {
    if(item<4){
        return true
    }
});
console.log(result)



//sort  
var array=[1,2,6,8,3,5]
var result=array.sort((a,b) => {
   return  a-b
});
console.log(result)


//map       
var array=[1,2,6,8,3,5]
var result=array.sort((item,index) => {
   return  ''+item+''
});
console.log(result)


//filter     
var array=[1,2,6,8,3,5]
var result=array.filter((item,index) => {
   if(item>=2){
       return true
   }
});
console.log(result)


//   api
for(var key in obj){

}