JavaScript Scope | LHS and RHS References.

These are quite helpful to understand how javascript engine dose work, here's what are LHS and RHS references dose mean.

LHS = Left Hand Side.
RHS = Right Hand Side.

LHS means the target of the assignment and RHS means the source of the assignment. Check the code below to get an clear idea.

function foo(a) {
    console.log( a ); // 2
}
foo( 2 );

Can you guess how many LHS references are in this code? there's only one. That is the parameter of the foo() function the variable a, because it's the target of the number 2 (a = 2). When we call that a variable inside the function, it's an RHS reference because we have already declared it and now we only looking for the source of the a not assigning some value to it.

Quiz
Check your understanding so far.

function buz(a) {
    var b = a;
    return a + b;
}

var c = buz( 4 );

  1. Identify all the LHS look-ups (there are 3!). 
  2. Identify all the RHS look-ups (there are 4!).
Answers
1. (a) (parameter of the buz function) , var b = and var c =.
2.  = a , a ++ b and buz(2);

Hello world!

Hello world! this is my first code snippet here and looking forward to update this blog as i'm learning, Hope this blog will help someone someday. :)

var hello = "Hello world!";

function sayHello(str){
    console.log(str);
};

sayHello(hello); // hello world!