Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!