Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Filter nested array based on _id

How to get item where id is: '60da3d5ce6cdd45d6dbc56bd'?

enter image description here

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Use

  • flat function => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat

  • filter function => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find

It will return the first value satisfying condition

Something like:

const data = [
  [{_id: 1}, {_id: 2}, {_id: 2}, {_id: '60da3d5ce6cdd45d6dbc56bd'}],
  [{_id: 1}, {_id: 2}, {_id: 2}],
  [{_id: 1}, {_id: 2}, {_id: 2}]
]

data.flat().find(e => e._id === '60da3d5ce6cdd45d6dbc56bd')
// output { _id: '60da3d5ce6cdd45d6dbc56bd' }

works just fine

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!