Node.js - Sample Interview Question (Junior Level)

What will be the result of the following code?

for(var i = 0; i < 10; i++) {
  setTimeout(function() {
      console.log(i);
  }, 0);
}

  1. 1 till 10 will be printed
  2. 1 till 9 will be printed
  3. 9 will be printed 10 times
  4. 10 will be printed 10 times
Tests in Node.js for Juniors

Test Name Difficulty Time (minutes) No. of Questions
Node.js Online Test for Juniors Node.js Junior 20 10