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

133
Views
Remove duplicates from javascript objects array based on object property value

i want to remove duplicates from javascript 'objects array' based on object property value

  var data = [
    {
      "John Doe": "john33@gmail.com",
    },
    {
      "William Smith": "william65@gmail.com",
    },
    {
      "Robert Johnson": "robert99@gmail.com",
    },
    {
      "John Smith": "john33@gmail.com",
    },
    {
      "James Johnson": "james8@gmail.com",
    },
  ];

here in the 'data' array there are same emails for "John Doe" and "John Smith", i want to remove one object of theme.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This can be done with Array.reduce(), combined with Object.values() as follows:

 var data = [
    {
      "John Doe": "john33@gmail.com",
    },
    {
      "William Smith": "william65@gmail.com",
    },
    {
      "Robert Johnson": "robert99@gmail.com",
    },
    {
      "John Smith": "john33@gmail.com",
    },
    {
      "James Johnson": "james8@gmail.com",
    },
  ];

const result = data.reduce((acc, o) => {
  if (!acc.map(x => Object.values(x)[0]).includes(Object.values(o)[0])) {
    acc.push(o);
  }
  return acc;
}, []);

console.log(result);

about 4 years ago · Juan Pablo Isaza 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!