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

118
Views
Could you help me understand the sequence of execution?
doA(function(){
  doB();
  doC(function() {
    doD();
  })
  doE();
});
doF();

excution order

doA() -> doF() -> doB() -> doC() -> doE() -> doD()

I don't understand why the execution order is as above...:(

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The order the functions are executed depends on how doA and doC call their respective callbacks

Synchronously

function doA(cb) { console.log('doA'); cb(); }
function doB() { console.log('doB'); }
function doC(cb) { console.log('doC'); cb(); }
function doD() { console.log('doD'); }
function doE() { console.log('doE'); }
function doF(cb) { console.log('doF');}

doA(function(){
  doB();
  doC(function() {
    doD();
  })
  doE();
});
doF();

or Asynchronously

function doA(cb) { console.log('doA'); setTimeout(cb); }
function doB() { console.log('doB'); }
function doC(cb) { console.log('doC'); setTimeout(cb); }
function doD() { console.log('doD'); }
function doE() { console.log('doE'); }
function doF(cb) { console.log('doF');}

doA(function(){
  doB();
  doC(function() {
    doD();
  })
  doE();
});
doF();

about 4 years ago · Juan Pablo Isaza Report
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!