map()
返回每次函数调用的结果组成的数组。
const array=[
{'id':'a','title':123},
{'id':'b','title':456},
{'id':'c','title':789},
];
let a=array.map((item,index,arr)=>{
return item.id
});
let b=array.map((item,index,arr)=>{
return item.title
});
console.log(a) //["a", "b", "c"]
console.log(b) //[123, 456, 789]
const array2=[1,2,3,4,5,6];
let c=array2.map((item,index,arr)=>{
return item*10
});
console.log(c) //[10, 20, 30, 40, 50, 60]