需求:
arr=[1,2]
obj=[{name:1,type:'111'},{name:2,type:'222'},{name:3,type:'333'}]
根据arr 查找obj对应的type 并把type写成数组 ['111','222']
实现:
reduce(callback,initialValue)
注:callback: functon(previousValue,currentValue,currentIndex,array)
arr=[1,2]
obj=[{name:1,type:'111'},{name:2,type:'222'},{name:3,type:'333'}]
根据arr 查找obj对应的type 并把type写成数组 ['111','222']
注:callback: functon(previousValue,currentValue,currentIndex,array)