Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda