js 数组操作

data["survey"]=data["survey"].sort((a, b) => b.scheduledDateTime.localeCompare(a.scheduledDateTime))

 最新时间显示在最前面

 

js 删除两个数组中id相同的对象

let arr1 = [{id:'1',name:'json'},{id:'2',name:'book'} ]
let arr2 = [{id:'1',name:'json',age:'15'},{id:'2',name:'book',age:'16'},{id:'3',name:'ani',age:'17'}] 
 //ES6的方法 
let add = arr2.filter(item => !arr1.some(ele=>ele.id===item.id)); 
cosnole.log(add); 

 

posted @ 2022-02-15 17:21  jahoon  阅读(23)  评论(0)    收藏  举报