📍 1. What is JavaScript and why is it important?
Answer: JavaScript is a dynamic, interpreted programming language that makes web pages interactive. It runs in browsers and on servers (Node.js), enabling features like animations, form validation, and API calls.
📍 2. Explain the difference between var, let, and const.
Answer:
var has function scope and is hoisted; let and const have block scope. const defines constants and cannot be reassigned.📍 3. What are closures in JavaScript?
Answer: Closures occur when a function remembers and accesses variables from its outer scope even after that outer function has finished executing.
📍 4. What is the Event Loop?
Answer: The Event Loop manages asynchronous callbacks by pulling tasks from the callback queue and executing them after the call stack is empty, enabling non-blocking code.
📍 5. What are Promises and how do they help?
Answer: Promises represent the eventual completion or failure of an asynchronous operation, allowing cleaner async code with
.then(), .catch(), and async/await.📍 6. Explain 'this' keyword in JavaScript.
Answer:
this refers to the context object in which the current function is executed — it varies in global, object, class, or arrow function contexts.📍 7. What is prototypal inheritance?
Answer: Objects inherit properties and methods from a prototype object, allowing reuse and shared behavior in JavaScript.
📍 8. Difference between == and === operators?
Answer:
== compares values after type coercion; === compares both value and type strictly.📍 9. How do you handle errors in JavaScript?
Answer: Using
try...catch blocks for synchronous code and .catch() or try-catch with async/await for asynchronous errors.📍 🔟 What are modules in JavaScript and their benefits?
Answer: Modules split code into reusable files with
import and export. They improve maintainability and scope management.💡 Pro Tip: Complement your answers with simple code snippets and real project scenarios wherever possible.
❤️ Tap for more!