JavaScript Interview Questions and Answers
Q1: What is the difference between '==' and '===' in JavaScript?
A1: '==' compares values after type coercion, whereas '===' compares both value and type without
coercion.
Q2: What are closures in JavaScript?
A2: A closure is a function that has access to its own scope, the outer function's scope, and the
global scope, even after the outer function has returned.
Q3: What is the event loop in JavaScript?
A3: The event loop is a mechanism that handles asynchronous operations by placing them in a
queue and executing them after the main stack is clear.
Q4: What is hoisting in JavaScript?
A4: Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope
before code execution.
Q5: What are promises in JavaScript?
A5: Promises represent the eventual completion (or failure) of an asynchronous operation and its
resulting value.