All quizzesMedium
Tricky Outputs
Preview — 3 of 10 questions
What is the output?
javascript
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 0);
}A0 1 2
B0 0 0
Cundefined undefined undefined
D3 3 3
What is the output?
javascript
function makeCounter() {
let count = 0;
return function () {
count++;
return count;
};
}
const counter = makeCounter();
console.log(counter());
console.log(counter());
console.log(counter());A1 2 3
B1 1 1
C0 1 2
D0 0 0
What is the output?
javascript
const obj = {
name: "Alice",
greet: function () {
setTimeout(function () {
console.log(this.name);
}, 0);
},
};
obj.greet();Aundefined
B"Alice"
CReferenceError
Dnull
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.