- "So, you think you know JavaScript?", answers explained by Zakas
- "Another JavaScript Quiz" by James Padolsey
- "JavaScript Quiz" from Perfection kills (exploring JavaScript by example)
Now, if you feel how twisted/unreasonable/difficult/loose JavaScript syntax is, you are not alone.
Several good readings that might help to clear things a bit:
After reading this article, it is now apparent why the function declaration has strange override behavior for the variable with a same name. The variable declaration+initialization gets a DontDelete flag and thus cannot be overridden.
This one explained what is function declaration, function expression and named function expression and bugs handling named function expression in various JavaScript engines. One note is that for the named function expression, the name/identifier can only be accessed in its function body.
The ultimate reference for underlying mechanisms of JavaScript.
Several good readings that might help to clear things a bit:
It is interesting that a variable can be declared after it is being used because the engine will hoist the variable declarations to the top of execution context. Also interesting to see that the engine breaks "var i = 1" into declaration part "var i;" and initialization part "i = 1;", and move the declaration to the top.
Another interesting note is that function declaration overrides a variable declaration with the same name, but cannot override the variable declaration+initialization.
Really a comprehensive explanation about how execution context, scope, variable attributes, etc. work in JavaScript. Now, finally I understand the difference between variable declaration+initialization (cannot be deleted) and undeclared assignment (can be deleted) because of the former one has DontDelete flag and the latter one does not.After reading this article, it is now apparent why the function declaration has strange override behavior for the variable with a same name. The variable declaration+initialization gets a DontDelete flag and thus cannot be overridden.
This one explained what is function declaration, function expression and named function expression and bugs handling named function expression in various JavaScript engines. One note is that for the named function expression, the name/identifier can only be accessed in its function body.
The ultimate reference for underlying mechanisms of JavaScript.
No comments:
Post a Comment