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

128
Views
Filter proprites from array of objects

I have this data coming from backend

[ { "total_spent": [ "greater_than", "less_than", "equal_to", "between" ] }, { "cart_value": [ "greater_than", "less_than", "equal_to", "between" ] }, { "shipping_price": [ "greater_than", "less_than", "equal_to", "between" ] }, { "product": [ "in" ] }, { "customer_type": [ "equal_to" ] } ]

And I am trying only to get total_spent and product and delete the rest.

I tried the following but I think it applies to objects.

filterConfi() {
      return ["cart_value", "shipping_price"].forEach(
         e => delete this.config.segmentationConfiguration[e]
      );
    },

The final result should look something like this

[ { "total_spent": [ "greater_than", "less_than", "equal_to", "between" ] }, { "product": [ "in" ] }, { "customer_type": [ "equal_to" ] } ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const arr = [ { "total_spent": [ "greater_than", "less_than", "equal_to", "between" ] }, { "cart_value": [ "greater_than", "less_than", "equal_to", "between" ] }, { "shipping_price": [ "greater_than", "less_than", "equal_to", "between" ] }, { "product": [ "in" ] }, { "customer_type": [ "equal_to" ] } ]

console.log(arr.filter(x=> !!x.total_spent || !!x.product))
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!