Skip to main content
added 41 characters in body
Source Link
cchamberlain
  • 18k
  • 7
  • 61
  • 72

Yes, thisbut not with the syntax you've proposed. This is easiest done when your path is an array of strings:

const tableData = (
  { profile: { firstname: 'jim', lastname: 'johnson' }
  }
)
                                                                    
const path = [ 'profile', 'firstname' ]

const valueAtPath = path.reduce((_, x) => _[x], tableData)

console.info(valueAtPath)

Yes, this is easiest done when your path is an array of strings:

const tableData = (
  { profile: { firstname: 'jim', lastname: 'johnson' }
  }
)
                                                                    
const path = [ 'profile', 'firstname' ]

const valueAtPath = path.reduce((_, x) => _[x], tableData)

console.info(valueAtPath)

Yes, but not with the syntax you've proposed. This is easiest done when your path is an array of strings:

const tableData = (
  { profile: { firstname: 'jim', lastname: 'johnson' }
  }
)
                                                                    
const path = [ 'profile', 'firstname' ]

const valueAtPath = path.reduce((_, x) => _[x], tableData)

console.info(valueAtPath)

Source Link
cchamberlain
  • 18k
  • 7
  • 61
  • 72

Yes, this is easiest done when your path is an array of strings:

const tableData = (
  { profile: { firstname: 'jim', lastname: 'johnson' }
  }
)
                                                                    
const path = [ 'profile', 'firstname' ]

const valueAtPath = path.reduce((_, x) => _[x], tableData)

console.info(valueAtPath)