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

175
Visualizações
How to import functions javascript

i need to export my functions from index.js

And use it in app.js like myFunction() Dont var.myFunction() And whithout using

{myFunction} = require("index.js")

Because i need import them all

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

0

Assign all functions in index.js to module.exports

for example , below content in your index.js

module.exports= { t: x=> console.log ('this is '+x), add: (x,y) => x+y}

to import them use

const myFunctions =require('index.js')

and then you can call myFunctions.add(2,3)

To learn more check module.exports in : https://learnjsx.com/category/2/posts/es6-moduleExports

about 4 years ago · Juan Pablo Isaza Relatório

0

Please learn more about the CommonJS module specification.

https://flaviocopes.com/commonjs/

Let's assume we have util.js.

exports.one = () => {}
exports.two = () => {}
exports.three = () => {}

Then as I know we can import everything like this.

const Util = require('utils.js');

Util.one()
Util.two()
Util.three()

Using ES6 syntax

import * as Util from 'utils.js'

Hope that answers your question.

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