比较时,尝试返回 的字段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 并在客户合同中返回的字段,因为我第一次使用过滤器因此面临问题。