ES6和ES5数组的方法 reduce map filter some every

// map(映射) filter some every find
 let map = [1,2,3].map(item=>item*2); //循环每一项 都*2
 let filter = [1,2,3].filter(item=>item!=2);//删除为2的 返回true的留下
 let some = [1,2,3].some(item=>item==5);
 let every = [1,2,4].every(item=>item==1);//看看有没有不等于1的。有的话返回false
 let find = [1,2,3].find(item=>item==1);//找到后返回找到的那一项,找不到的返回undefind
 let includes = [1,2,3].includes(3)

 let key = ['name','age'];
 let value = ['hj',26];
 let r = key.reduce((moen,current,index)=>(moen[current] = value[index],moen),{});

你可能感兴趣的:(es6,js,前端,es6,javascript)