Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
nodejs
promises
02callback_settimeout2.js
02callback_settimeout2.js
/** * callback example */ function cb() { console.log('\n 1st callback is executed!'); console.log('BEFORE 2nd CALLBACK'); setTimeout(function () { console.log('\n 2nd callback is executed'); }, 2000); console.log('AFTER 2nd CALLBACK'); } console.log('BEFORE 1st CALLBACK'); setTimeout(cb, 3000); console.log('AFTER 1st CALLBACK'); /* $node 02callback_settimeout2 BEFORE 1st CALLBACK AFTER 1st CALLBACK 1st callback is executed! BEFORE 2nd CALLBACK AFTER 2nd CALLBACK 2nd callback is executed */
Reload page
Preview
W3C validation
Edit Code
JS Console