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

159
Vistas
Is more or less efficient to use a stand alone function than a callback in JavaScript?

I'm new to JavaScript and recently learned about callbacks via a tutorial. The instructor mentioned that callbacks are used everywhere in code amongst JavaScript developers. What I understand so far is that these callbacks store a function within a function to be executed at a later time, but wouldn't it be simpler and more efficient to store a value in a variable and create a function that logs your desired output? Can’t the callback alternative (typed below) be executed at a later time as well? 

// Callback Example:
     
function callbackExample(name, callback){
    log(callback(name)); 
}

callbackExample('Adee Otana', function(name){
    return 'Hello ' + name; 
}); 
     
     
// Alternative: 

let name = 'Adee'; 
 
function callbackAlt(name){
    log('Hello ' +  name); 
}
 
callbackAlt(name); 
about 4 years ago · Juan Pablo Isaza
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