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

176
Vistas
What does "function(err, result)" in JavaScript

I don't understand what does this code do in JavaScript. Why it is used? As far as I know it is "callback" but how the data assigned to "result"? I've never seen an information explains that.

 var prompt = require('prompt');
 prompt.start();
 prompt.get(['name'], function (err, result) {
 console.log('  name: ' + result.name);
 });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When you run a function that uses the callback, all you're doing is giving it another function for it to run when it is done. In your case, you are giving the prompt.get function the "function (err, result) {...}" function. When prompt.get is done and wants to return some result, it will call this function that you gave it. The function, as you can see, has parameters that can be passed to it (in your case, err and result). When it runs the callback (just like running any other function), it will give it parameters that are then exposed to the callback function you gave it.

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