Emilis
Emilis

Reputation: 162

Javascript filter nested array object

I want to filter this data: enter image description here

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. So basicaly I dont want user int this array with given facebookid.

Any help would be perfect. I tried deconstruct it like this : enter image description here 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'))

Upvotes: 0

Views: 70

Answers (1)

EugenSunic
EugenSunic

Reputation: 13693

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)

Upvotes: 1

Related Questions