Q&A Quiz
1. What is the difference between let and var in JavaScript?
Answer: The let keyword allows you to declare block-scoped variables that are only accessible
within the block of code where they are defined, while var declares function-scoped variables
that can be accessed throughout the function in which they are defined.
2. What is the difference between null and undefined in JavaScript?
Answer: Undefined is a primitive data type in JavaScript that indicates a variable has not been
assigned a value, while null is an object that represents the intentional absence of any object
value.
3. What is the difference between == and === in JavaScript?
Answer: The double equals (==) operator compares two values for equality, allowing type
coercion if necessary, while the triple equals (===) operator compares two values for strict
equality, without type coercion.
4. What is a closure in JavaScript?
Answer: A closure is a function that has access to its outer function's variables, even after the
outer function has returned.
5. What is the difference between synchronous and asynchronous JavaScript?
Answer: Synchronous JavaScript executes one task at a time, blocking other tasks until the
current one is complete, while asynchronous JavaScript can execute multiple tasks
simultaneously, without blocking the execution of other tasks.
6. What is the role of the Document Object Model (DOM) in JavaScript?
Answer: The DOM is a programming interface that allows JavaScript to manipulate the content
and structure of a web page in real time, by dynamically modifying its HTML, CSS, and other
elements.
7. What is the difference between an object and an array in JavaScript?
Answer: An object is a collection of key-value pairs, where each key represents a unique
identifier and each value represents a data value, while an array is an ordered list of values,
accessed by their numerical index.