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

76
Views
Is there a way to directly assign to object what we destructure?

I am sure what I am trying to accomplish can be done in a much simpler way. I unpack multiple fields and then I add the filtered object to an array.

const filteredPersons = [];
const {state, name, age, weight, gpa, diet} = person;
filteredPersons.push({state, name, age, weight, gpa, diet});

When I try something like this, it does not work:

const filteredPerson = {state, name, age, weight, gpa, diet} = person;
filteredPersons.push(filteredPerson);

This causes repetition and it looks really ugly.

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

0

If there just couple of props you dont need to include from person means, you can use the following.

const filteredPersons = [];
const { unwanted1, unwanted2, ...restProps } = person;
filteredPersons.push(restProps);
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!