I can understand how this works what it does but, just can’t grasp the grouping this into RHS and LHS. I can understand The engine, complier, and scope tasks from the book. Any tips for LHS and RHS ? function foo(a) { var b = a; return a + b; } var c = foo( 2 );
LHS = Variable assignment, or writing to memory. Think saving a text file to your hard drive.
RHS = Variable lookup, or reading from memory. Think opening a text file from your hard drive.
So, var b is LHS because the engine wants to write something to memory. Then the a is RHS because it wants to get that value from memory.
// first, we have a function 'foo' with the parameter 'a'
function foo (a) { // and, when we run this function ....
// it creates the variable 'b', and the value that has a parameter 'a' (2), assign to variable 'b'
var b = a; // 'b' becomes 2
// then, it returns the sum of these two values ( 'a' and 'b' or 2 and 2 in this case )
return a + b;
}
// assign a value that returns a function 'foo' with the parameter '2' to variable 'c'
var c = foo (2);