Some help needed with the Quiz:
Question 5:
function bar() {
return foo;
foo = 10;
function foo() {}
var foo = '11';
}
alert(typeof bar());
Q: What is alerted? A: function.
Based on this tutorial, even it does not say that clearly and this is probably my misinterpretation, I was expecting the following behavior, when bar()
gets called:
- Function
foo()
added to the lexical environment ofbar()
. var foo = '11';
overrides this definition, leavingfoo
undefined.- When
return foo;
is executed,foo
is undefined.
What happens in the initialization? Any links for good documentation?
Question 12:
String('Hello') === 'Hello';
Q: what is the result? A: true.
I thought String()
would return an object and 'Hello'
is a primitive string, thus the answer would be "false". Why is it "true"?
Question 20:
NaN === NaN;
Q: what is the result? A: false.
What is the logic? What happens here?