I was reading the Scopes and Closure title of You don't know JS by Kyle Simpson, specifically this topic Compiler Speak. This section is about the kind of Lookups the engine uses. Now I understand what is LHS or RHS lookup to the extent given in this section.
My problem is the note saying that function declaration of the form function fx(a) {..
is not a LHS lookup. There is an explanation given for the same, but I am unable the understand. Here is the whole note
You might be tempted to conceptualize the function declaration function
foo(a) {...
as a normal variable declaration and assignment, such asvar foo
andfoo = function(a){...
. In so doing, it would be tempting to think of this function declaration as involving an LHS look-up. However, the subtle but important difference is that Compiler handles both the declaration and the value definition during code-generation, such that when Engine is executing code, there’s no processing necessary to “assign” a function value tofoo
. Thus, it’s not really appropriate to think of a function declaration as an LHS look-up assignment in the way we’re discussing them here.
Any kind of clarification would be helpful. Even on LHS and RHS lookups.