JavaScript
JavaScript
May 31, 2025 at 09:50 AM
*JavaScript core interview questions with answers* *1. What is JavaScript?* JavaScript is a high-level, interpreted scripting language used to make web pages interactive. *2. Difference between var, let, and const?* - `var`: function-scoped, hoisted. - `let`: block-scoped, no hoisting. - `const`: block-scoped, immutable reference. *3. What are data types in JavaScript?* Primitive: string, number, boolean, null, undefined, symbol, bigint Non-primitive: objects, arrays, functions *4. What is hoisting in JavaScript?* Variable and function declarations are moved to the top of their scope during compilation. *5. What are closures?* A closure is a function that remembers variables from its outer scope even after the outer function has closed. *6. Difference between == and ===?* - `==`: checks value (type coercion) - `===`: checks value and type *7. What is an IIFE (Immediately Invoked Function Expression)?* A function that runs as soon as it is defined: `(function(){...})();` *8. What is a callback function?* A function passed into another function as an argument to be executed later. *9. What is the difference between null and undefined?* - `null`: intentional absence of value. - `undefined`: a variable declared but not assigned. *10. What is event bubbling?* An event propagates from the target element up to the root. *11. What are arrow functions?* Shorter syntax for functions and do not bind their own `this`: `const add = (a, b) => a + b;` *12. What is a promise?* An object representing the eventual completion or failure of an async operation. *13. What is async/await?* Syntax to write async code that looks synchronous and handles promises more cleanly. *14. What are template literals?* String literals allowing embedded expressions: `` `Hello ${name}` `` *15. Difference between map, filter, and reduce?* - `map`: transforms array elements. - `filter`: removes unwanted elements. - `reduce`: combines all elements into one value. *16. What is destructuring?* Extracting values from arrays/objects into variables: `const { name } = obj;` *17. What is the spread operator (...) in JavaScript?* Expands elements from an array or object: `[...arr]`, `{...obj}` *18. What is the difference between synchronous and asynchronous code?* - Synchronous: blocks execution - Asynchronous: non-blocking, handled via callbacks/promises/async-await *19. What is the DOM?* Document Object Model – a tree structure representing the page, allowing JS to access and manipulate HTML elements. *20. What is event delegation?* Attaching a single event listener to a parent element to handle events from its children. *Double TAP ❤️ for more!*
❤️ 👍 😂 🇮🇳 👌 💙 🙃 🙏 116

Comments