TGViewer
Web Development - HTML, CSS & JavaScript Web Development - HTML, CSS & JavaScript @javascript_courses · 55.7K subscribers
Post #3163 6.86K
✅ Top Javascript Interview Questions with Answers: Part-3 💻✨

21. What is the event loop in JS?
The event loop manages execution of tasks (callbacks, promises) in JavaScript. It continuously checks the call stack and task queues, executing code in a non-blocking way — enabling asynchronous behavior. 🔄

22. Explain microtask vs. macrotask queue
- Microtasks: Promise callbacks, queueMicrotask, MutationObserver — run immediately after the current operation finishes. ⚡
- Macrotasks: setTimeout, setInterval, I/O — run after microtasks are done. ⏳

23. What is JSON and how is it used?
JSON (JavaScript Object Notation) is a lightweight data-interchange format used to store and exchange data. 📁
const obj = { name: "Alex" };
const str = JSON.stringify(obj); // convert to JSON string
const newObj = JSON.parse(str); // convert back to object


24. What are IIFEs (Immediately Invoked Function Expressions)?
Functions that execute immediately after being defined. 🚀
(function() {
console.log("Runs instantly!");
})();


25. What is the difference between synchronous and asynchronous code?
- Synchronous: Runs in order, blocking the next line until the current finishes. 🛑
- Asynchronous: Doesn’t block, allows other code to run while waiting (e.g., fetch calls, setTimeout). ✅

26. How does JavaScript handle memory management?
JS uses automatic garbage collection — it frees up memory by removing unused objects. Developers must avoid memory leaks by cleaning up listeners, intervals, and unused references. ♻️

27. What is a JavaScript engine?
A JS engine (like V8 in Chrome/Node.js) is a program that parses, compiles, and executes JavaScript code. ⚙️

28. Difference between deep copy and shallow copy in JS
- Shallow copy: Copies references for nested objects. Changes in nested objects affect both copies. 🤝
- Deep copy: Creates a complete, independent copy of all nested objects. 👯
const original = { a: 1, b: { c: 2 } };
const shallow = { ...original }; // { a: 1, b: { c: 2 } } - b still references original.b
const deep = JSON.parse(JSON.stringify(original)); // { a: 1, b: { c: 2 } } - b is a new object


29. What is destructuring in ES6?
A convenient way to unpack values from arrays or properties from objects into distinct variables. ✨
const [a, b] = [1, 2]; // a=1, b=2
const {name} = { name: "John", age: 25 }; // name="John"


30. What is a spread operator (...) in ES6?
The spread operator allows an iterable (like an array or string) to be expanded in places where zero or more arguments or elements are expected, or an object expression to be expanded in places where zero or more key-value pairs are expected. 🥞
const nums = [1, 2];
const newNums = [...nums, 3]; // [1, 2, 3]

const obj1 = { a: 1 };
const obj2 = { ...obj1, b: 2 }; // { a: 1, b: 2 }

💬 Double Tap ❤️ For Part-4!

#JavaScript #JSInterview #CodingInterview #Programming #WebDevelopment #Developer #AsyncJS #ES6
  • ❤ 18
More from @javascript_courses
  1. Oct 9, 2026🇮🇳 𝗚𝗢𝗩𝗘𝗥𝗡𝗠𝗘𝗡𝗧 𝗢𝗙 𝗜𝗡𝗗𝗜𝗔 — 𝗔𝗜𝗖𝗧𝗘 𝗜𝗡𝗧𝗘𝗥𝗡𝗦𝗛𝗜𝗣𝗦 𝟮𝟬𝟮𝟲 🚀…
  2. Oct 8, 2026🎓 𝗠𝗶𝗰𝗿𝗼𝘀𝗼𝗳𝘁 𝗙𝗥𝗘𝗘 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 𝘄𝗶𝘁𝗵 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗲𝘀! 🚀🔥 Upgr…
  3. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  4. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  5. Oct 4, 2026DSA Handwritten Notes
  6. Sep 28, 2026To learn web design and development from basic to advanced levels, you can follow these st…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →