Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
Javascript optional chaining on dynamic path

Is there a way to perform Javascript optional chaining on dynamic path.

say I have, a dynamicPath = 'information.person.names.first_name'

If the path was known, I could have done data?.information?.person?.names?.first_name

I have searched and found out that if we have a single path, say dynamicPath = 'first_name' We can easily do data?.[dynamicPath] and get the value.

Can we have some way of doing data?.[dynamicPath] or something similar with the entire path of the object? If the value is 'information.person.names.first_name' then JS would treat the entire string as a key and value would be undefined.

I know we can achieve this with lodash _.get method but we are trying to avoid its use.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda