Essential JS interview questions for Fresher’s

Rafi Aman
2 min readMay 8, 2021

1. Is there any difference between “null” and “undefined”?

undefined means the value of variable or object is not defined, whereas null means empty, there is no value. null is primitive value, we can set any variable’s value to null, but if we don’t define it then it will give undefined. We can get undefined in many occasions:

  • If we declare a variable without assigning any value to it.
  • return statements that do not return anything.
  • Function parameters that have not passed.

2. What are the difference between “==” and “===”?

The main difference is “==” will not check types and “===” will check whether both sides are of same type. “===” compares the types and values in both side. Of both sides are not same type, answer is always false. For example, if you are comparing two strings, they must have identical character sets.

3. What is Truthy and Falsy values?

  • null
  • false
  • undefined
  • 0
  • NaN

These values are called Falsy values. Hence, There are only two truthy things- true and everything that is not false.

4. How to differentiate Global scope and Block scope?

Simply, anything that is global can be accessible from anywhere in the code. but one thing to be remembered anything outside of a function is global. Now Block scope is anything that is surrounded by curly braces.

5. Tell us Something about Closure?

If you have a function within a function, execution of the inner function will create a scope inside of the outer function. Because the inside function scope is enclosed by the outer function scope, the inner function scope is called a closure. If you don’t need to call a function within a function

That’s it for today, I will keep update this post regarding questions.

Happy Coding.

--

--