JavaScript Interview Question!!!

What are Truthy and Falsy values?

1. What is Truthy Value?

In JavaScript, a value is truthy if JavaScript’s built-in type coercion converts it to true. Every value is either truthy or falsy, so any value that isn't falsy it’s must be the truth.

2. What is Falsy Value?

Falsy Value, A falsy value is a value that is considered false when encountered in a Boolean context. Examples of falsy values in JavaScript…

What is the difference between Null vs Undefined?

3. What is the Null value?

The value Null represents the intentional absence of any object value. It is one of JavaScript's primitive values and is treated as falsy for boolean operations.

4. What is an Undefined value?

The Undefined property indicates that a variable has not been assigned a value, or not declared at all. It is also one of JavaScript's primitive types.

What is the difference between double equal and triple equal?

5. What is Double Equal?

Actually, Double Equals (==) checks for value equality only. It inherently does type coercion. This means that before checking the values, it converts the types of the variables to match each other.

6. What is Triple Equal?

On the other hand, Triple Equals (===) does not perform type coercion. It will verify whether the variables being compared have both the same value AND the same type.

What are Hoisting, Scope, Global Scope, and Local Scope?

7. What is hoisting?

Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution. Here is the JavaScript lifecycle and indicative of the sequence in which variable declaration and initialization occur.

8. What is Scope?

The scope is the accessibility of variables, functions, and objects in some particular part of your code during runtime. In other words, scope determines the visibility of variables and other resources in areas of your code.

In the JavaScript language there are two types of scopes:

  • Global Scope
  • Local Scope

9. What is Global Scope?

Global Scope variables defined outside any function, block, or module scope it’s called the global scope. A variable is in the Global scope if it’s defined outside of a function.

10. What is Local Scope?

In which Variables are declared inside any of the functions that are called the local variables. It’s cannot be accessed outside any of the function declarations.