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

400
Views
removing a column from an array in javascript

I have a multidimentional array in javascript like this

Arr[i].ProductId
Arr[i].ProductName
Arr[i].ProductCode
Arr[i].ProductDescription
Arr[i].ProductOrigin
Arr[i].ProductInfo

Arr is populated with data when everything is done with Arr,I want to have another array without (ProductCode,ProductOrigin,ProductInfo) columns.

I have done this

var list2 = JSON.parse(JSON.stringify(Arr));
for (i in list2) {
    delete list2[i].ProductCode;
    delete list2[i].ProductOrigin;
    delete list2[i].ProductInfo;
}

this is iterating through the array. is it possible to remove the Columns without iterating? or what is the better solution for that?

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

0

You need to iterate over the list to get the new version of every element. Another way to do this is using Array#map:

const list2 = Arr.map(({ ProductCode, ProductOrigin, ProductInfo, ...e }) => e);
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!