简体   繁体   English

Javascript 过滤器嵌套数组 object

[英]Javascript filter nested array object

I want to filter this data:我想过滤这些数据: 在此处输入图像描述

I have 4 users in this example, all of them has key fbid there is stored facebookID if it matches given key user should be deleted from array.在这个例子中我有 4 个用户,他们都有密钥 fbid,如果它与给定的密钥用户匹配,则存储 facebookID,应该从数组中删除。 So basicaly I dont want user int this array with given facebookid.所以基本上我不希望用户使用给定的 facebookid 这个数组。

Any help would be perfect.任何帮助都是完美的。 I tried deconstruct it like this:我试着像这样解构它: 在此处输入图像描述 But dont know how to filter it now但是现在不知道怎么过滤

Tried this: Object.entries(userMap).map(([key, value]) => Object.entries(value[1]).filter(value[1]['fbid'] == '315151515'))试过这个: Object.entries(userMap).map(([key, value]) => Object.entries(value[1]).filter(value[1]['fbid'] == '315151515'))

I think you want something like this我想你想要这样的东西

 var arr = [ [{ fbid: 111 }], [{ fbid: 222 }], [{ fbid: 333 }] ] const searchedFbid=222 const result = arr.filter(x =>.x.some(({ fbid }) => fbid === searchedFbid)) console.log(result)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM