JavaScript Interview Questions and Answers
Q: What is JavaScript?
A: JavaScript is a scripting language used to create dynamic content on websites.
Q: Difference between var, let, and const?
A: var is function-scoped, let and const are block-scoped. const can't be reassigned.
Q: What are closures?
A: Closures are functions that retain access to variables from their lexical scope.
Q: What is hoisting?
A: Hoisting moves variable and function declarations to the top of their scope.
Q: What is the difference between == and ===?
A: == checks value equality, === checks value and type.
Q: Explain event delegation.
A: It allows you to handle events at a higher level and catch events from child elements.
Q: What is a promise?
A: A promise represents a future value, used for async operations.
Q: What is async/await?
A: Syntactic sugar over promises for cleaner asynchronous code.
Q: What are arrow functions?
A: Concise syntax for writing functions, does not bind its own `this`.
Q: What is the DOM?
A: Document Object Model represents HTML structure in JS.