Set去重
var array = [1,1,1,2,3,4,4,5,6];
var a = new Set(array );
var b = [];
b = [...a]//[1,2,3,4,5,6] 去重效果
Map数据映射 可以重组数据
var a = [{ id: 1, name: 'zhangsan' }, { id: 2, name: 'zhangsi' }, { id: 3, name: 'wangwu' }];
var c = a.map(obj => {
let oS = {};
oS['ids'] = obj.id;
oS['bbName'] = obj.name;
return oS;
})// c = [{ ids: 1, bbName: 'zhangsan' }, { ids: 2, bbName: 'zhangsi' }, { ids: 3, bbName: 'wangwu' }]
filter数据过滤
var a = [{ id: 1, name: 'zhangsan' }, { id: 2, name: 'zhangsi' }, { id: 3, name: 'wangwu' }];
var c = a.filter(obj => {
if(obj.id === 3)
return obj;
})// c = [ { id: 3, name: 'wangwu' }]