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

114
Views
filter the array of object on the basis of key name in javascript

I Have array of object like below

 employees = [
    {name: "Tony Stark", department: "IT"},

    {name: "Peter Parker", department: "Pizza Delivery"},


    {name: "Bruce Wayne", department: "IT"},

    {name: "Clark Kent", department: "Editing"}
];

and I want to filter array of object like

 employees = [
    {name: "Tony Stark"},

    {name: "Peter Parker"},


    {name: "Bruce Wayne"},

    {name: "Clark Kent"}
];
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could use map()

const employees = [
  { name: "Tony Stark", department: "IT" },
  { name: "Peter Parker", department: "Pizza Delivery" },
  { name: "Bruce Wayne", department: "IT" },
  { name: "Clark Kent", department: "Editing" }
];

const result = employees.map(({ name }) => ({ name }));

console.log(result);

const employees = [
  { name: "Tony Stark", department: "IT" },
  { name: "Peter Parker", department: "Pizza Delivery" },
  { name: "Bruce Wayne", department: "IT" },
  { name: "Clark Kent", department: "Editing" }
];

const result = employees.map((employee) => { 
  return { 
    name: employee.name 
  }
});

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!