【发布时间】:2019-09-07 08:15:19
【问题描述】:
尝试返回array1的字段和array2的另一个字段,进行比较。
我有两个对象数组(客户和客户)。我想返回客户 ID 和客户名称,其中客户 ID 等于客户 ID。为此,我想使用地图、过滤器,但不知道如何使用下面是我的尝试,
let clientcontract=this.state.addclient.filter(client=>{
return(
this.state.customer.filter(cust=>{
return (
cust.id===client.id // comparing customer and client id
)
})
)
});
这种方法用于获取客户 ID 和客户 ID 相同但不知道如何获取客户名称和客户 ID 并在客户合同中返回的字段,因为我第一次使用过滤器所以面临问题在里面。
【问题讨论】:
标签: javascript arrays reactjs ecmascript-6 es6-map