DEV Community

Maegan Wilson
Maegan Wilson

Posted on • Originally published at maeganwilson.micro.blog on

LHS & RHS Look Ups

LHS and RHS stand for Left Hand Side and Right Hand Side of an assignment operation. This allows for us to break down the code and analyze exactly what is happening.

For the first part post, we are going to be analyzing the following program

This program actually breaks the LHS and RHS look ups into two different statements.

The LHS of the assignment operation will look up the variable container and assigns a value to that container. In the program, var a = 2; looks for the variable a and assigns it the value of 2, so that categorizes the statement as a LHS look up.

The RHS of the assignment operation will look up a value of a variable. In the program, console.log(a); looks for the value of a and outputs that value, which in this case is 2.

Now, let’s look at a program that has both a LHS and a RHS look up.

The LHS look up of this program is foo(2);. That is because when foo is called, a is assigned the value 2. The RHS look up in this program is console.log(a); since the program has to look up the value of a to perform the console.log.


If you enjoy my posts, please consider sharing it or Buying me a Coffee!

Buy Me A Coffee

Top comments (0)