Important Questions About JavaScript.

MH HABIB
2 min readMay 8, 2021
  1. What is the difference between undefined and null in JavaScript?

Answer: When a variable is declared only but its value is not set then it gives an undefined output. Null is an empty value and it needs to set explicitly by a programmer. If any variable has no value then the programmer defined it as null.

2. What is the difference between double equal (==) and triple equal (===) in JavaScript?

Answer: Double equal (==) and triple equal (===) both are comparison variables. In JavaScript double equal (==) is used to compare two variables by ignoring the data type of the variables whereas triple equal (===) considers both value and data type during comparison.

3. What is variable scope?

Answer: Variable scope refers to the accessibility of a variable in JavaScript. There are two types of variables depending on the scope of JavaScript. They are Local variable, Global Variable.

The scope of a local variable is inside a block, but the scope of a global variable is in the entire code.

4. What is hoisting?

Answer: Hoisting is a JavaScript mechanism where variables and functions are moved to the top of their scope before the execution of the code. If the variable is declared using the keyword var, it moves to the top of the program and set as undefined as a global variable before the execution of the code. This phenomenon is known as hoisting.

5. What is a closure?

Answer: Closure is an important concept in JavaScript. A closure gives an opportunity to get access to an outer function’s scope from the inner function. Closures are created every time whenever a function is created at function creation time.

6. What is DOM?

Answer: DOM is the short form of ‘Document Object Model’. It is a programming interface of XML and HTML documents. When a web page is loaded on a browser then the browser creates a Document Object Model for the webpage. This Document Object Model is constructed as a tree using the objects of the webpage.

7. What is an API?

Answer: API is the short form of Application Programming Interface. Using APIs programmers can handle more complex functionalities in an easy way. I also extend the functionality of a web browser.

8. What is recursion?

Answer: Recursion is a process where a function calls itself. The function that is calling itself is called the recursive function.

9. Define callback function?

Answer: A callback function is a function that passed into another function as an argument, which is then invoked inside the outer function to complete some kind of action.

10. What is Event Bubbling in JavaScript?

Answer: Event bubble is a JavaScript term that happens when an event handler called an event that is nested inside another element and both elements have registered a listener for the same event. In other words, an event bubble occurs when an event happens on an element, it first runs the handlers on it, then runs on its parent, then all the way up on other ancestors.

--

--