TL;DR
-
JS is a compiled language.
-
LHS (Left-Hand Side) & RHS (Right-Hand Side)
-
Var/Func declaration is more standard terminology than var/func definition
-
If you use an LHS var that hasn’t been declared before, JS will ask each parent function scope until it reaches the global scope. If in strict mode, it will throw an error, but if not in strict mode, the global scope will automatically create an LHS var for that variable name. This means if you use a variable without declaring it first, that variable will belong to the global scope (if not using strict mode).
-
Named func exp vs anonymous func exp: the name of a named func exp will ONLY be registered in the local scope of that function and not registered in the outer scope (the scope of the var pointing to that func exp) -> If you want to use recursion inside a func exp (A), there’s no other way to call func A itself except by naming func A (meaning A must be a named func exp, not an anonymous func exp) OR func exp A through the var that already points to it (if using this method, JS will have to look up the name first in the local scope, when it doesn’t find an RHS ref to this func, it will have to go to the outer scope to find it -> only then will it find the var pointing to that func -> wastes time). => Func exp is better than func declaration, but you should use named func exp because: 5.1 You can self-reference inside the func block. 5.2 Debugging is easier 5.3
-
…