@jgCarroll/

orderLoggedOut

JavaScript

A common interview question

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
function logNumbers() {
  console.log(1); 
  setTimeout(function(){console.log(2)}, 1000); 
  setTimeout(function(){console.log(3)}, 0); 
  console.log(4);
}
 
logNumbers();

// the event loop for the third console log adds some bit of delay to it being logged
Native Browser JavaScript