Array.prototype.map()和Array.prototypefilter()

ES5 => 筛选功能  Array.prototypefilter():
代码:
var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
 
Array.prototype.map()和Array.prototypefilter()
ES5 => 数组的处理 Array.prototype.map()
代码:
var array1 = [1, 4, 9, 16];

// pass a function to map
const map1 = array1.map(x => x * 2); console.log(map1);
// expected output: Array [2, 8, 18, 32]
 
 
 
Array.prototype.map()和Array.prototypefilter()
 
 
 
 
 
 
上一篇:深入理解 Array.prototype.map()


下一篇:spring自带测试配置