10 most important Javascript Interview Questions

Mahadi Hasan
4 min readMay 8, 2021

Q1. What are the differences between (==) and (===)?

If I can explain simply (==) check only Value whatever it’s a different type. And the other hand (===) check Value and Type. Let’s see an example

var number = 0;
var boolean= false;
var string = '0';
console.log(number == number); // true
console.log(number == boolean); // true
console.log(number == string); // true
console.log(number === number); // false
console.log(number === boolean); // false
console.log(number === string); // false

If you give (==) to check each other. Then you can notice that they make the second value into the same type. It’s really confusing to big work.

Q2. How many “Scope” has Javascript?

First of all, we need to know What is Scope? Mainly scope is an area. As a function, if-else, class, etc is an area.

  1. Global Scope: When you declared a variable in the root scope then you can access it. And another thing is if you declared a variable with var then you can access it anywhere, that is called a global variable.
  2. Local Scop: On the other side Local variable is, When you declared a variable inside a scope like function, if-else, class, etc, that time you only use this variable locally means inside that scope. You can’t access outside the scope. That's called the local variable.

Q3. What is Closure in Javascript?

The closure is an interesting thing in Javascript. When a function returns another function or using another function that time second function make a close environment a store previous value, that called closure.

Q4. What is the difference between .bind(), .call(), .apply()?

An object has a method and you want to use that method by the borrow, that time you can use .bind(), .call(), .apply().

.bind(): When you want to use a method of an object to another object, then you use .bind().

.call(): It’s like to bind method, but when you want to call the method, you need to pass “this” keyword as a first argument. Then the rest of the parameters will pass by comma(,) separation.

.apply(): Apply method is the same as the Call method but when you pass the rest of the parameter then you will pass by Array[] separation.

Q5. What is (this) in JavaScript?

If I tell simply: ‘this’ is the object that is executing the current function.

Q6. What is the event loop in Javascript?

Event loop mainly Javascript run-time concept. Javascript has three thing Stack, Queue, Heap

Javascript works synchronously. They execute first work then next. When they finished all work synchronously then he starts Queue/waiting list’s work. It’s a run-type execution of Javascript.

Simplify: Javascript starts his work synchronously means stack’s work. After finishing the stack’s work then started waiting for work means queue work. It’s a Javascript run-time concept.

Q7. Differentiate between Real DOM and Virtual DOM.

Real DOM

  1. It updates to show.
  2. Can directly update HTML.
  3. Create a new DOM if element updates.
  4. DOM manipulation is very expensive.
  5. Too much memory wastage.
Real DOM

Virtual DOM

  1. It updates faster.
  2. Can’t directly update HTML,,
  3. Updates the JSK if element updates.
  4. DOM manipulation is very easy.
  5. No memory wastage.

Q8. Why can’t browsers read JSX?

Browser can only read JavaScript object but JSX is not a regular Javascript object. Thus to enable a browser to read JSX, first, we need to transform the JAX file into a Javascript object using JSX transformers like Babel and then pass it to the browser.

Q9. What is the Callback function?

A callback function is a function that passed to some method as an argument. It is a function that is to be executed after another function has finished executing, hence the name ‘Call back function’.

function callback(name) {
console.log('Hello ' + name);
}
function mainFunction(callbackValue) {
var name = 'Mahadi';
callbackValue(name);
}
mainFunction(callback);

Q10. “In React, everything is a component.” Explain.

Components are the building blocks of a React application’s UI. These components split up the entire UI into small independent and reusable pieces. Then it renders each of these components independent of each other without affecting the rest of the UI.

--

--

Mahadi Hasan
0 Followers

I'm a Web base Software Engineer. I have 3 years of experience in this field.