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

73
Visualizações
Export list ESM from JSON

I would like to export a list using ESM from a JSON object. Let's say I have the following object:

const myList = {
    func1: function(){},
    func2: function(){}
}

And would like to export it such as:

export {myList.func1 as func1, myList.func2 as func2}

Is there a nice way to export all the functions (assuming we have a lot more functions) in myList such as each function inside it can be imported with its name (e.g. import {func1} from './myList.js')

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

a) There is no such thing as a "JSON object". JSON is always a string; if it's an object, it's Javascript. JSON also cannot store functions.

That being said, you can make use of destructuring here:

export { func1, func2 } = myList;
about 4 years ago · Juan Pablo Isaza Relatório
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