}
x;
The things in if can definitely be executed because it is an actual existence (object). Non-null|underfined objects can be continued under if. However, they are the same as above. The principle, f , does not exist.
So 1undefined is returned.
var x = [typeof x, typeof y][1];
typeof typeof x;
Here, typeof y ,undefined. Then, typeof typeof undefined => vtypeof "undefined"
Returns "string".
(function(foo){
return typeof foo.bar;
})({ foo: { bar: 1 } });
Hehe, here It’s a little trap, it’s easy to get in if you look too fast.
A brief description, var fo = {foo:{bar:1}}; function(foo){})(fo);
return typeof foo.bar ==> return typeof fo.bar
So return "undefined".
(function f(){
function f(){ return 1; }
return f();
function f(){ return 2; }
})();
This question is about the compiler's analysis of function. It doesn't matter about return. When he sees return as just a string, compile The processor has parsed all functions. This is different from var f = function(){}.
So, it will return 2.
function f(){ return f; }
new f() instanceof f;
I don’t understand this place enough, and the explanation given by Bottle seems to be understandable
new f() gets f itself, not a new object, so it is not an instance of f.
So, return false.
with (function(x, undefined){}) length;
Regarding with, if I regard with as a function (the same as alert).
Then this length, which is the length of the formal parameter of with.
Return to 2.
Okay. It seems that many issues about js still need to be sorted out. Aiming is a big book, and the explanation on this part is very powerful. It allows people to bypass some traps and problems. The rest is some own testing.
These questions cannot completely reflect a person's js ability, but at least they can let people know how the compiler works Processing js