Interview bank track

Browser and DOM

DOM, events, rendering pipeline, storage, and browser APIs.

3 topics20 interview questions with answers
Browser and DOM1-3y

DOM Events and Event Delegation

Cover bubbling, capturing, target vs currentTarget, and scalable event handling.

Open study topic
domevent-bubblingdelegationbrowser
Beginner

Beginner interview questions

2 questions

Start with simple definitions, the main idea, and the basic mistakes interviewers expect you to avoid.

screening
Beginner
Explain DOM Events and Event Delegation in very simple words.
Easy answer

When you click a child element, the event can move up to parents. Event delegation uses one parent listener to handle many children.

Interview-ready answer

When you click a child element, the event can move up to parents. Event delegation uses one parent listener to handle many children. Easy picture: Instead of giving every student a separate bell, the class monitor listens once and checks which student raised a hand.

Example

Instead of giving every student a separate bell, the class monitor listens once and checks which student raised a hand.

Why interviewers ask this

Interviewers often begin with a basic question to see whether you truly understand the concept instead of repeating memorized jargon.

domevent-bubblingdelegationbrowser
Common follow-ups
  • Events flow through capture, target, and bubble.
  • Delegation means one parent listener handles many children.
  • Use closest() to find the intended element.
screening
Beginner
What are the first basics to remember about DOM Events and Event Delegation?
Easy answer

target is origin. currentTarget is where the listener sits. Delegation reduces listener count. Check semantics and keyboard access too.

Interview-ready answer

target is origin. currentTarget is where the listener sits. Delegation reduces listener count. Check semantics and keyboard access too.

Example

Instead of giving every student a separate bell, the class monitor listens once and checks which student raised a hand.

Why interviewers ask this

This checks whether you can give a short, calm answer before the interviewer adds depth or follow-ups.

domevent-bubblingdelegationbrowser
Common follow-ups
  • Confusing target with currentTarget.
  • Forgetting some events behave differently for bubbling.
1-3 Years

1-3 Years interview questions

2 questions

Cover common screening and theory questions that prove you know the fundamentals and can answer clearly.

theory
1-3 Years
What points should a 1-3 year frontend developer cover for DOM Events and Event Delegation?
Easy answer

Events flow through capture, target, and bubble. Delegation means one parent listener handles many children. Use closest() to find the intended element. Pair click behavior with keyboard behavior.

Interview-ready answer

Events flow through capture, target, and bubble. Delegation means one parent listener handles many children. Use closest() to find the intended element. Pair click behavior with keyboard behavior.

Example

Instead of giving every student a separate bell, the class monitor listens once and checks which student raised a hand.

Why interviewers ask this

This checks whether you can give a clean interview answer without getting lost in too much detail.

domevent-bubblingdelegationbrowser
Common follow-ups
  • target is origin.
  • currentTarget is where the listener sits.
  • Delegation reduces listener count.
coding
1-3 Years
What is event delegation and why is it useful?
Easy answer

Event delegation puts one listener on a parent and handles child interactions by checking the event target.

Interview-ready answer

It uses bubbling so a stable parent can manage many dynamic child elements. It reduces listener count, works well for changing lists, and is common in practical DOM interactions like menus, tables, and autocomplete results.

Example

list.addEventListener('click', (event) => { const target = event.target as HTMLElement; const item = target.closest('[data-item-id]');

Why interviewers ask this

This checks whether you can apply the concept in code and explain the reasoning, not only define it.

domeventsbrowser
Common follow-ups
  • What is the difference between target and currentTarget?
  • Which events do not bubble the way you expect?
3-6 Years

3-6 Years interview questions

1 questions

Focus on mid-level answers with practical examples, tradeoffs, and implementation thinking.

theory
3-6 Years
How would you answer DOM Events and Event Delegation in a mid-level frontend interview?
Easy answer

When you click a child element, the event can move up to parents. Event delegation uses one parent listener to handle many children.

Interview-ready answer

The DOM supports capture, target, and bubbling phases. Most handlers run during bubbling. Event delegation attaches a single listener to a stable ancestor and checks event.target or closest() to handle child interactions efficiently. It reduces listener count and works well for dynamic lists or machine-coding rounds.

Example

list.addEventListener('click', (event) => { const target = event.target as HTMLElement; const item = target.closest('[data-item-id]');

Why interviewers ask this

Mid-level rounds expect more than definitions. They want structured explanation, correct terminology, and practical judgment.

domevent-bubblingdelegationbrowser
Common follow-ups
  • Events flow through capture, target, and bubble.
  • Delegation means one parent listener handles many children.
  • Use closest() to find the intended element.
  • Pair click behavior with keyboard behavior.
Expert

Expert interview questions

1 questions

Practice high-signal follow-ups around architecture, pitfalls, debugging, scale, and leadership-level judgment.

design
Expert
What tradeoffs, pitfalls, and production issues do you discuss for DOM Events and Event Delegation in an expert-style round?
Easy answer

When you click a child element, the event can move up to parents. Event delegation uses one parent listener to handle many children. The main thing to avoid is: Confusing target with currentTarget.

Interview-ready answer

The DOM supports capture, target, and bubbling phases. Most handlers run during bubbling. Event delegation attaches a single listener to a stable ancestor and checks event.target or closest() to handle child interactions efficiently. It reduces listener count and works well for dynamic lists or machine-coding rounds. Common pitfalls: Confusing target with currentTarget. Forgetting some events behave differently for bubbling. Ignoring keyboard support while handling clicks. Related areas to connect in follow-ups: HTML, CSS, and Accessibility Foundations, Machine Coding Round Approach.

Example

list.addEventListener('click', (event) => { const target = event.target as HTMLElement; const item = target.closest('[data-item-id]');

Why interviewers ask this

Senior-leaning interviewers test whether you can move from definitions into tradeoffs, debugging, scale, and connected system thinking.

domevent-bubblingdelegationbrowser
Common follow-ups
  • What real bug or production issue can this topic cause?
  • What tradeoff would make you choose one approach over another?
  • How would you explain this decision in a code review or design discussion?
Browser and DOM3-6y

Browser Render Pipeline and Main Thread Thinking

Explain parsing, style, layout, paint, compositing, and what makes the browser feel janky.

Open study topic
browserrender-pipelinelayoutpaintmain-thread
Beginner

Beginner interview questions

2 questions

Start with simple definitions, the main idea, and the basic mistakes interviewers expect you to avoid.

screening
Beginner
Explain Browser Render Pipeline and Main Thread Thinking in very simple words.
Easy answer

The browser reads HTML and CSS, calculates sizes and positions, paints pixels, and finally shows the page. If we force too much work on the main thread, the page feels slow or jumpy.

Interview-ready answer

The browser reads HTML and CSS, calculates sizes and positions, paints pixels, and finally shows the page. If we force too much work on the main thread, the page feels slow or jumpy. Easy picture: It is like setting up a classroom: first read the seating plan, then place desks, then paint the labels, and only then let students enter. If you keep moving desks while painting, everything becomes messy and slow.

Example

It is like setting up a classroom: first read the seating plan, then place desks, then paint the labels, and only then let students enter. If you keep moving desks while painting, everything becomes messy and slow.

Why interviewers ask this

Interviewers often begin with a basic question to see whether you truly understand the concept instead of repeating memorized jargon.

browserrender-pipelinelayoutpaintmain-thread
Common follow-ups
  • The browser parses markup and styles first.
  • Layout decides sizes and positions.
  • Paint and compositing draw the final result.
screening
Beginner
What are the first basics to remember about Browser Render Pipeline and Main Thread Thinking?
Easy answer

Parse, style, layout, paint, composite. Avoid layout thrashing. Measure first when animations feel janky. Main-thread time is UX time.

Interview-ready answer

Parse, style, layout, paint, composite. Avoid layout thrashing. Measure first when animations feel janky. Main-thread time is UX time.

Example

It is like setting up a classroom: first read the seating plan, then place desks, then paint the labels, and only then let students enter. If you keep moving desks while painting, everything becomes messy and slow.

Why interviewers ask this

This checks whether you can give a short, calm answer before the interviewer adds depth or follow-ups.

browserrender-pipelinelayoutpaintmain-thread
Common follow-ups
  • Memorizing pipeline words without connecting them to user-visible lag.
  • Reading layout and writing styles repeatedly in tight loops.
1-3 Years

1-3 Years interview questions

2 questions

Cover common screening and theory questions that prove you know the fundamentals and can answer clearly.

theory
1-3 Years
What points should a 1-3 year frontend developer cover for Browser Render Pipeline and Main Thread Thinking?
Easy answer

The browser parses markup and styles first. Layout decides sizes and positions. Paint and compositing draw the final result. Extra main-thread work directly hurts smoothness.

Interview-ready answer

The browser parses markup and styles first. Layout decides sizes and positions. Paint and compositing draw the final result. Extra main-thread work directly hurts smoothness.

Example

It is like setting up a classroom: first read the seating plan, then place desks, then paint the labels, and only then let students enter. If you keep moving desks while painting, everything becomes messy and slow.

Why interviewers ask this

This checks whether you can give a clean interview answer without getting lost in too much detail.

browserrender-pipelinelayoutpaintmain-thread
Common follow-ups
  • Parse, style, layout, paint, composite.
  • Avoid layout thrashing.
  • Measure first when animations feel janky.
theory
1-3 Years
What happens in the browser from receiving HTML to showing pixels on the screen?
Easy answer

The browser parses HTML and CSS, builds structures for them, calculates layout, paints pixels, and composites layers to show the final screen.

Interview-ready answer

A strong answer covers parsing, style calculation, layout, paint, and compositing. I also connect those stages to real frontend behavior: layout-sensitive reads can trigger extra work, frequent style changes can create jank, and heavy main-thread JavaScript delays rendering and interaction. Interviewers care more about whether you can connect the pipeline to actual performance decisions than whether you only recite the stage names.

Example

const width = card.offsetWidth; card.style.width = width + 24 + 'px'; // Repeated layout reads and writes inside a loop can create layout thrashing.

Why interviewers ask this

This is a common interview question used to test clarity, correctness, and how calmly you explain fundamentals.

browserrenderinglayoutpaint
Common follow-ups
  • What is layout thrashing?
  • Which CSS properties are cheaper to animate?
3-6 Years

3-6 Years interview questions

2 questions

Focus on mid-level answers with practical examples, tradeoffs, and implementation thinking.

theory
3-6 Years
How would you answer Browser Render Pipeline and Main Thread Thinking in a mid-level frontend interview?
Easy answer

The browser reads HTML and CSS, calculates sizes and positions, paints pixels, and finally shows the page. If we force too much work on the main thread, the page feels slow or jumpy.

Interview-ready answer

I explain browser work as parse, style calculation, layout, paint, and compositing. Performance problems often happen when JavaScript repeatedly reads layout-sensitive values and writes styles in a loop, causing extra reflow work. I connect that to main-thread availability, animation smoothness, and user-perceived responsiveness rather than only saying the pipeline names.

Example

const width = card.offsetWidth; card.style.width = width + 24 + 'px'; // Repeated layout reads and writes inside a loop can create layout thrashing.

Why interviewers ask this

Mid-level rounds expect more than definitions. They want structured explanation, correct terminology, and practical judgment.

browserrender-pipelinelayoutpaintmain-thread
Common follow-ups
  • The browser parses markup and styles first.
  • Layout decides sizes and positions.
  • Paint and compositing draw the final result.
  • Extra main-thread work directly hurts smoothness.
coding
3-6 Years
What is layout thrashing and how do you avoid it in frontend code?
Easy answer

Layout thrashing happens when code repeatedly reads layout values and writes styles in a pattern that forces extra recalculation work.

Interview-ready answer

This usually happens when JavaScript mixes layout reads like offsetWidth with style writes inside loops or repeated update cycles. The browser has to stop and recalculate layout more often than necessary. I avoid it by batching reads before writes, reducing DOM churn, using transform or opacity for animation when possible, and keeping expensive updates away from tight interaction loops.

Example

const width = card.offsetWidth; card.style.width = width + 24 + 'px'; // Repeated layout reads and writes inside a loop can create layout thrashing.

Why interviewers ask this

This checks whether you can apply the concept in code and explain the reasoning, not only define it.

browserperformancelayout-thrashing
Common follow-ups
  • Why are transform and opacity preferred for many animations?
  • How would you detect this in DevTools?
Expert

Expert interview questions

1 questions

Practice high-signal follow-ups around architecture, pitfalls, debugging, scale, and leadership-level judgment.

design
Expert
What tradeoffs, pitfalls, and production issues do you discuss for Browser Render Pipeline and Main Thread Thinking in an expert-style round?
Easy answer

The browser reads HTML and CSS, calculates sizes and positions, paints pixels, and finally shows the page. If we force too much work on the main thread, the page feels slow or jumpy. The main thing to avoid is: Memorizing pipeline words without connecting them to user-visible lag.

Interview-ready answer

I explain browser work as parse, style calculation, layout, paint, and compositing. Performance problems often happen when JavaScript repeatedly reads layout-sensitive values and writes styles in a loop, causing extra reflow work. I connect that to main-thread availability, animation smoothness, and user-perceived responsiveness rather than only saying the pipeline names. Common pitfalls: Memorizing pipeline words without connecting them to user-visible lag. Reading layout and writing styles repeatedly in tight loops. Assuming every animation should be JavaScript-driven. Related areas to connect in follow-ups: DOM Events and Event Delegation, Loading Strategy, Caching, and Core Web Vitals, React Performance Toolkit.

Example

const width = card.offsetWidth; card.style.width = width + 24 + 'px'; // Repeated layout reads and writes inside a loop can create layout thrashing.

Why interviewers ask this

Senior-leaning interviewers test whether you can move from definitions into tradeoffs, debugging, scale, and connected system thinking.

browserrender-pipelinelayoutpaintmain-thread
Common follow-ups
  • What real bug or production issue can this topic cause?
  • What tradeoff would make you choose one approach over another?
  • How would you explain this decision in a code review or design discussion?
Browser and DOM3-6y

Browser Storage, Caching, and Networking

Cover localStorage, sessionStorage, cookies, cache behavior, and request lifecycle tradeoffs.

Open study topic
browserstoragecookiescachingnetwork
Beginner

Beginner interview questions

2 questions

Start with simple definitions, the main idea, and the basic mistakes interviewers expect you to avoid.

screening
Beginner
Explain Browser Storage, Caching, and Networking in very simple words.
Easy answer

Browsers can remember data in different places. Each option has a purpose, a size limit, and a security or lifetime tradeoff.

Interview-ready answer

Browsers can remember data in different places. Each option has a purpose, a size limit, and a security or lifetime tradeoff. Easy picture: Think of browser storage like school storage spaces: a desk drawer for this class, a locker for your own items, and an office register for things that must travel with every form.

Example

Think of browser storage like school storage spaces: a desk drawer for this class, a locker for your own items, and an office register for things that must travel with every form.

Why interviewers ask this

Interviewers often begin with a basic question to see whether you truly understand the concept instead of repeating memorized jargon.

browserstoragecookiescachingnetwork
Common follow-ups
  • Choose storage by scope, lifetime, and security need.
  • Cookies are request-aware, localStorage is not.
  • Cache strategy matters for freshness and speed.
screening
Beginner
What are the first basics to remember about Browser Storage, Caching, and Networking?
Easy answer

localStorage is persistent but synchronous. sessionStorage is per-tab. Cookies travel with requests. Cache rules shape perceived speed.

Interview-ready answer

localStorage is persistent but synchronous. sessionStorage is per-tab. Cookies travel with requests. Cache rules shape perceived speed.

Example

Think of browser storage like school storage spaces: a desk drawer for this class, a locker for your own items, and an office register for things that must travel with every form.

Why interviewers ask this

This checks whether you can give a short, calm answer before the interviewer adds depth or follow-ups.

browserstoragecookiescachingnetwork
Common follow-ups
  • Using localStorage for sensitive auth data without understanding risk.
  • Treating cookies and browser storage as interchangeable.
1-3 Years

1-3 Years interview questions

2 questions

Cover common screening and theory questions that prove you know the fundamentals and can answer clearly.

theory
1-3 Years
What points should a 1-3 year frontend developer cover for Browser Storage, Caching, and Networking?
Easy answer

Choose storage by scope, lifetime, and security need. Cookies are request-aware, localStorage is not. Cache strategy matters for freshness and speed. Persistence and auth should not be mixed blindly.

Interview-ready answer

Choose storage by scope, lifetime, and security need. Cookies are request-aware, localStorage is not. Cache strategy matters for freshness and speed. Persistence and auth should not be mixed blindly.

Example

Think of browser storage like school storage spaces: a desk drawer for this class, a locker for your own items, and an office register for things that must travel with every form.

Why interviewers ask this

This checks whether you can give a clean interview answer without getting lost in too much detail.

browserstoragecookiescachingnetwork
Common follow-ups
  • localStorage is persistent but synchronous.
  • sessionStorage is per-tab.
  • Cookies travel with requests.
screening
1-3 Years
What is the difference between localStorage, sessionStorage, and cookies?
Easy answer

localStorage is persistent and browser-side, sessionStorage is tab-scoped, and cookies are small values sent with matching HTTP requests.

Interview-ready answer

I compare them by lifetime, scope, and request behavior. localStorage survives reloads and browser restarts but is synchronous and unsuitable for secrets. sessionStorage is scoped to one tab session. Cookies are smaller, can be sent automatically with requests, and matter when server communication or auth behavior is involved. A good answer also mentions that these tools solve different problems and should not be chosen only because they are familiar.

Example

localStorage.setItem('theme', 'dark'); sessionStorage.setItem('draft-tab', 'billing'); document.cookie = 'locale=en; Path=/; Secure; SameSite=Lax';

Why interviewers ask this

This is a common interview question used to test clarity, correctness, and how calmly you explain fundamentals.

browserstoragecookies
Common follow-ups
  • Why is localStorage risky for sensitive data?
  • When would cookies be preferable?
3-6 Years

3-6 Years interview questions

2 questions

Focus on mid-level answers with practical examples, tradeoffs, and implementation thinking.

theory
3-6 Years
How would you answer Browser Storage, Caching, and Networking in a mid-level frontend interview?
Easy answer

Browsers can remember data in different places. Each option has a purpose, a size limit, and a security or lifetime tradeoff.

Interview-ready answer

I compare browser storage by scope, lifetime, and sensitivity. localStorage is easy but synchronous and inappropriate for sensitive secrets. sessionStorage is tab-scoped. Cookies are small, automatically sent with matching requests, and useful when server communication matters. I then connect this to caching headers, stale data, retry logic, and how frontend apps should avoid mixing persistence, cache, and auth concerns carelessly.

Example

localStorage.setItem('theme', 'dark'); sessionStorage.setItem('draft-tab', 'billing'); document.cookie = 'locale=en; Path=/; Secure; SameSite=Lax';

Why interviewers ask this

Mid-level rounds expect more than definitions. They want structured explanation, correct terminology, and practical judgment.

browserstoragecookiescachingnetwork
Common follow-ups
  • Choose storage by scope, lifetime, and security need.
  • Cookies are request-aware, localStorage is not.
  • Cache strategy matters for freshness and speed.
  • Persistence and auth should not be mixed blindly.
design
3-6 Years
How do browser caching and stale data affect frontend design?
Easy answer

Caching can make apps feel fast, but the UI must still handle old data, refresh timing, and clear signals about what is fresh or stale.

Interview-ready answer

I separate static asset caching from API data freshness. Long-lived caching is great for hashed assets because the content changes with the filename. API data is different because the same endpoint can return updated information. Frontend design has to decide whether to revalidate in the background, show stale content while refreshing, or block until fresh data arrives. Interviewers want to hear that speed and correctness are both product decisions.

Example

localStorage.setItem('theme', 'dark'); sessionStorage.setItem('draft-tab', 'billing'); document.cookie = 'locale=en; Path=/; Secure; SameSite=Lax';

Why interviewers ask this

This checks your decision-making, tradeoffs, and ability to discuss the bigger picture.

browsercachingnetworkdata-fetching
Common follow-ups
  • What is stale-while-revalidate in simple words?
  • How would you show stale state in the UI?
Expert

Expert interview questions

1 questions

Practice high-signal follow-ups around architecture, pitfalls, debugging, scale, and leadership-level judgment.

design
Expert
What tradeoffs, pitfalls, and production issues do you discuss for Browser Storage, Caching, and Networking in an expert-style round?
Easy answer

Browsers can remember data in different places. Each option has a purpose, a size limit, and a security or lifetime tradeoff. The main thing to avoid is: Using localStorage for sensitive auth data without understanding risk.

Interview-ready answer

I compare browser storage by scope, lifetime, and sensitivity. localStorage is easy but synchronous and inappropriate for sensitive secrets. sessionStorage is tab-scoped. Cookies are small, automatically sent with matching requests, and useful when server communication matters. I then connect this to caching headers, stale data, retry logic, and how frontend apps should avoid mixing persistence, cache, and auth concerns carelessly. Common pitfalls: Using localStorage for sensitive auth data without understanding risk. Treating cookies and browser storage as interchangeable. Ignoring cache invalidation and stale data behavior. Related areas to connect in follow-ups: Frontend Security, Auth, and Trust Boundaries, Realtime Dashboards and Resilient Data Flow, Loading Strategy, Caching, and Core Web Vitals.

Example

localStorage.setItem('theme', 'dark'); sessionStorage.setItem('draft-tab', 'billing'); document.cookie = 'locale=en; Path=/; Secure; SameSite=Lax';

Why interviewers ask this

Senior-leaning interviewers test whether you can move from definitions into tradeoffs, debugging, scale, and connected system thinking.

browserstoragecookiescachingnetwork
Common follow-ups
  • What real bug or production issue can this topic cause?
  • What tradeoff would make you choose one approach over another?
  • How would you explain this decision in a code review or design discussion?