一个json数组,根据日期来对应筛检属性publishtime为发布日期,循环的时候希望创建一个数组publishtime只出现一次的值后面如果重复都不出现,比如May.13现在出现3次,那要实现以后就是只有第一次出现May.13的时候保留这个字段其他全部删除[{"length":"02:50","channel":"笑点集装箱","vid":"1a665661c9bfdf9","title":"如果有一天siri控制了人类…","gender":0,"image":"http://7xiqwt.com2.z0.glb.qiniucdn.com/image/1eb46ae2ec8bcc1baad174c11...","avator":"http://7xiqwt.com2.z0.glb.qiniucdn.com/image/46755e0014e5a74babae13cee...","click":42219,"chid":"21ddc47f57e79f2","publishtime":"Now"},{"length":"01:01","channel":"冉冉是Vimeo的搬运工","vid":"1bfef4c4ccae113","title":"如果你还没有吃夜宵,看看这支片","gender":2,"image":"http://7xiqwt.com2.z0.glb.qiniucdn.com/image/d9b2a7b2a1f402eafcfe2464c...","avator":"http://7xiqwt.com2.z0.glb.qiniucdn.com/image/cf782ac9cd01dd9fe5b62285f...","click":421,"chid":"9eb01af2093606e","publishtime":"May.13"},{"length":"01:23","channel":"为了报仇看电影","vid":"e0621d6ece5c448","title":"复仇者联盟的生活聚会里都在玩些什么","gender":2,"image":"http://7xiqwt.com2.z0.glb.qiniucdn.com/image/7be260d5edda9f11f268b75d7...","avator":"http://7xiqwt.com2.z0.glb.qiniucdn.com/image/51c9acd51dce33e06730bb172...","click":90,"chid":"85b8379357b2e16","publishtime":"May.13"},{"length":"03:53","channel":"道理要从街上学","vid":"15a6623fb5a5d4b","title":"这3个学生对流浪汉做的事感动了1千万人","gender":0,"image":"http://7xiqwt.com2.z0.glb.qiniucdn.com/image/ff305c1bd0761c87e2c9105f0...","avator":"http://7xiqwt.com2.z0.glb.qiniucdn.com/image/6cd7be40224688f9e2412a7b5...","click":19665279,"chid":"3a8048d007fa98e","publishtime":"May.13"}]
2 回答
红颜莎娜
TA贡献1842条经验 获得超12个赞
(functionaa(list){for(vari=0,len=list.length;ifor(varj=i+1;j if(list[i].publishtime===list[j].publishtime){ list.splice(j,1);j--;len--;}}}})(list);我写了一个,不知道是否完全符合你的要求,试一下吧,第一次评论,吼吼好紧张,别喷我~~
慕村9548890
TA贡献1884条经验 获得超4个赞
我也来一发:functionfilter(target){varresult=[];result.push(target.shift());for(vari=0;iif(result.length>i&&result[i].publishtime!=target[i].publishtime){ result.push(target[i]);}}returnresult;}filter(array);
添加回答
举报
0/150
提交
取消