10 Most Important JavaScript Interview Questions Everyone Should Know

Lahaduzzaman Lahad
4 min readMay 8, 2021

JavaScript is an open-source and most popular client-side scripting language supported by all browsers. Today I am going to talk about the 10 Most Important JavaScript Interview Questions Everyone Should Know. Let’s start:

1. Double Equal vs Triple Equal:

Double equal checks only the value of the operands where triple equal checks both values and type. Actually, double equal coverts the type in a common type to compare just value.

2. Closures:

Closure means that an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned. You have learned that we can create nested functions in JavaScript. The inner function can access variables and parameters of an outer function (however, cannot access the arguments object of the outer function). Consider the following example:

function OuterFunction() {

var outerVariable = 1;

function InnerFunction() {
alert(outerVariable);
}

InnerFunction();
}

In the above example, InnerFunction() can access outerVariable.

3.NaN:

When there is an error while operating a number, then NaN is generated. It first converts the tested value to a Number, then tests it for the result. It returns a Boolean value, true if the value is NaN, else false.

4.Scope:

In the JavaScript language there are two types of scopes:

  • Global Scope
  • Local Scope

Variables defined inside a function are in local scope while variables defined outside of a function are in the global scope. Each function when invoked creates a new scope.

5.Event Bubbling:

Event bubbling is when an event will traverse from the most inner nested HTML element and move up the DOM hierarchy until it arrives at the element which listens for the event.

6.JavaScript Hoisting:

Hoisting is a concept in JavaScript, not a feature. In JavaScript, variable and function names can be used before declaring it. The JavaScript compiler moves all the declarations of variables and functions at the top so that there will not be any error. This is called hoisting.

7.Difference between “null” and “undefined” :

“null” means empty or nothing, not exist anything. We use null for checking whether there exists anything or not. Also, there was anything and we collect from there and it's empty for checking it we use null.

var demo = null;
alert(demo); //shows null
alert(typeof demo); //shows object

“undefined” use when declarer variable but if we don’t assign anything in the variable, then it will show undefined. Another example is when we call a function then if we don’t return it then it will show undefined.

var demo;
alert(demo); //shows undefined
alert(typeof demo); //shows undefined

8.Purpose of “This” Keyword in JavaScript:

JavaScript “this” keyword refers to the object it belongs to. This has different values depending on where it is used. In a method, this refers to the owner object and in a function, this refers to the global object. It can’t be set by assignment during execution, and it may be different each time the function is called.

9.DRY:

DRY is an acronym that stands for Don’t Repeat Yourself. It usually means refactoring code by taking something done several times and turning it into a loop or a function. DRY code is easy to change because you only have to make any change in one place. Whenever you finish writing some code, you should always look back to see if there is any way you can DRY it up, including using descriptive variable names, taking repetitive bits of code, and extracting them into a function or loop.

10. API in JavaScript:

API means Application Programming Interface. A Browser API can extend the functionality of a web browser. They abstract more complex code away from you, providing some easier syntax to use in its place. All browsers have a set of built-in Web APIs to support complex operations and to help to access data.

Hope you get a great idea about the Most Important JavaScript Interview Questions from this. I will come with more articles in the next few days. Till then stay tuned and follow me.

Thank You ♥️

--

--