JS Interview Question #2 (Accidental Global Variable)
Think1s
Posted on March 22, 2022
Visit think1s to get more such questions.
Revise Accidental Global Variable concepts to answer this questions.
What is the output the following code?
function getNumber() {
var a = b = 2;
a++;
return a;
}
console.log(typeof a);
console.log(typeof b);
To know the answer click here
What is the output the following code?
function getNumber() {
var a = b = 2;
a++;
return a;
}
getNumber();
console.log(typeof a);
console.log(typeof b);
To know the answer click here
💖 💪 🙅 🚩
Think1s
Posted on March 22, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.