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

164
Views
how to chnage values of object coming in nested array

Im trying to chnage the object values in map loop on nested array

Object Examples

var data = [[{name: 'test', values: [{isSelected: true}] }]]



 var resertData = data.map(filterArray => {
    return filterArray.map(filter => {
        return filter.values.map(values => {
            return values.isSelected = false
        })
    })
})

required output should be

[[{name: 'test', values: [{isSelected: false}] }]]

and Im getting with my code

'[[[false]]]'

Please help me guys

Thanks in advance :)

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

0

Well clearly returning just the changed fields overwrites existing ones. Return entire objects specifying values of fields you want to change, and use object destructuring to preserve existing ones. Try this:

    var resertData = data.map(filterArray => {
    return filterArray.map(filter => {
        return {
            ...filter,
            values : filter.values.map(values => {
                return {isSelected : false}
            })

        }
    })
})
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!