In this post, we will see list of javascript interview questions

What is the difference between == and === ?

  • == compares values for equality after type coercion, meaning that if the two values being compared have different types, JavaScript will try to convert them to a common type before making the comparison. For example, "5" == 5 would evaluate to true.
  • ===, on the other hand, compares values for equality without type coercion. This means that "5" === 5 would evaluate to false as the values have different types.
  • It is generally recommended to use === instead of == in JavaScript, as it avoids unexpected type coercion and makes the code more predictable.

What are the differences between let, var and const ?

Here are the differences between let and other ways of declaring variables in JavaScript:

  1. let is a keyword in JavaScript that is used to declare variables with block scope
  2. var: Variables declared with var have function scope, meaning they are accessible within the entire function in which they are declared, regardless of block scope.
  3. const: Variables declared with const have block scope, like let, but their value cannot be re-assigned after declaration. This makes them useful for declaring constants.


if (true) {
  var x = "var";
  let y = "let";
  const z = "const";

console.log(x); // "var"
console.log(y); // ReferenceError: y is not defined
console.log(z); // ReferenceError: z is not defined

In this example, var is accessible outside the if block, while let and const are not, as they are only accessible within the block they are declared in.

What is the difference between class and an object in JavaScript?

Please go through this post for more details :

What is the use of ‘this’ keyword and how does it work?

Please go through this post for answer :

Explain hoisting in JavaScript?

Please go through this post for answer:

What is closure in JavaScript and how it works?

Please go through this post for answer :

What is an anonymous function and how to use it in JavaScript?

Please go through this post for answer :

How do you handle errors in JavaScript?

Errors in JavaScript can be handled using try...catch statements. The try block contains code that may throw an error, while the catch block contains code that will handle the error if it occurs.

Here’s an example of how to use try...catch statements in JavaScript:

try {
  // code that may throw an error
  let x = y + 1;
} catch (error) {
  // code to handle the error

What is the use of typeof operator in JavaScript?

The typeof operator in JavaScript is used to determine the data type of a given value.

typeof “Hello World ==> String

tyoeof 50 ==> number

How to declare an array in JavaScript and what are the different methods to add elements to an array?

What is the difference between null and undefined in JavaScript?

Thanks for Reading.. Please visit below link for Javascript advanced Interview Questions