01-this series of questions directed front end surface ------------

What to ask output is the code?

Here Insert Picture Description

answer:

Here Insert Picture Description

Analysis:
1. Questions about the js this point, and that is who calls this point who
2. In the first implementation of fn () method, the direct execution of fn at this time, the call is not any object at this time this is a pointer to the window, this.length naturally window.length, direct printing and length, no length fn of variable in the current scope, it will be up to find one scope variable length, that window looking in, it is obviously, the result is the output 10
3. second performance arguments [0] (), the case corresponds arguments.fn (), this case is directed arguments, so the printed arguments of naturally this.length length, the length of the first direct printing performed the same time
4. method direct Print this obj is invoked method, so this point is pointing obj, so this case corresponds to the print this.length obj.length == "5
directly print length is the same as with the first execution fn

Released eight original articles · won praise 55 · views 6647

Guess you like

Origin blog.csdn.net/Newbie___/article/details/101167728