🧠
Q1. Microtasks vs macrotasks?
A. Microtasks (Promise callbacks) run before the next macrotask (setTimeout, I/O) tick.
Advanced
🧠
Q2. What is a memory leak in JS?
A. Unreleased references keep objects alive (globals, listeners not removed, caches).
Advanced
🧠
Q3. Garbage collection (high-level)?
A. Most engines use tracing GC; unreachable objects are collected (mark-and-sweep variants).
Advanced
🧠
Q4. Module scope and tree-shaking?
A. ES modules have their own scope; bundlers can remove unused exports (tree-shaking).
Advanced
🧠
Q5. How do you prevent XSS?
A. Escape output, avoid injecting HTML, sanitize if necessary, and use CSP.
Advanced
🧠
Q6. What is SSR hydration mismatch?
A. When server-rendered HTML differs from client render, hydration can warn or break and cause UI issues.
Advanced
🧠
Q7. What is AbortController used for?
A. To cancel fetch requests and other async operations that support abort signals.
Advanced
🧠
Q8. What is event capture?
A. Events can travel down first (capture) then bubble up; capture listeners use capture=true.
Advanced