I am not understanding the Quiz 1 ques 2. Please Explain that question.
Quiz 2 Question
Hi @mansisingh2803,
The question states to predict the output of the following code
var foo = 'I am foo';
function test() { var foo = 'I am foodoo'; }
console.log(foo);
Here the output will be ‘I am foo’ and the reason for the same will be because the variable foo is Redefined as var foo = ‘I am foodoo’ . This wouldn’t have happened if only it would have been reassigned then the value of foo would have been I am foodoo but here it is redefined/redeclared and therefore the output doesn’t change as the program identifies the previous foo only .The newly defined foo will have the scope of the test function. To read and know more bout scope kindly visit the link.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
Thanku for the explaination . I got it.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.