DOM Manipulation
Traversal, events, serialization and building a tiny virtual DOM.
1.Explain the concept of debouncing and throttling
Run after activity stops versus at most once per interval, with implementations and use cases.
2.How do you type event handlers in React with TypeScript?
Synthetic event types, handler aliases, target vs currentTarget, and DOM listener types.
3.What is virtual DOM in React?
An in-memory description of the UI that React diffs to update the real DOM.
4.Star Rating
Build a star rating input with hover preview, keyboard support and a clear button, built on native radios.
5.Lowest Common Ancestor
Find the closest shared ancestor of two nodes in a DOM-like tree.
6.Event Emitter
Implement an EventEmitter class with on, off and emit, the observer pattern behind Node's events module and DOM events.
7.Event Emitter II
Extend an event emitter with once, unsubscribe handles, bulk off and listener counts, with well-defined behaviour during emit.
8.getElementsByClassName
Find every descendant element that has all of the given class names by walking the DOM tree yourself.
9.getElementsByTagName
Return every descendant element with a given tag name (or all of them for "*") by traversing the DOM tree.
10.Pub/Sub Store (Mini Redux)
Implement createStore with getState, dispatch and subscribe: the core of Redux in about 50 lines.
11.How does virtual DOM in React work? What are its benefits and downsides?
Render, diff with type and key heuristics, commit, and the costs of doing so.
12.Explain the Observer pattern and its use cases
Subjects notifying subscribers: event emitters, EventTarget, stores and their pitfalls.
13.Tooltip and Popover
Build an accessible hover/focus tooltip and a click-triggered popover, and explain when to use each.
14.Backbone Model
Build an observable Model class with defaults, get/set/unset, per-attribute change events, previous values and silent updates.
15.Table of Contents
Build a nested table of contents from the h1–h6 headings in a document, generating unique anchor ids and rendering it as nested lists.
16.Virtual DOM Diff (Keyed Children)
Patch the real DOM from an old and a new virtual tree, reusing nodes by type and key and moving keyed children instead of recreating them.
17.Virtual DOM: createElement and render
Implement h() to build virtual DOM nodes and render() to turn them into real DOM, with attributes, styles, events and function components.
18.Selectable Cells (Drag Select)
Build a grid where dragging selects a rectangle of cells, with modifier-key multi-select and a full keyboard equivalent.
19.Wordle
Build a Wordle clone with physical and on-screen keyboards, correct duplicate-letter scoring and accessible feedback.
20.jQuery Class Manipulation
Build a tiny $ wrapper with chainable addClass, removeClass, toggleClass and hasClass that work on every matched element.
21.jQuery CSS
Implement a $(selector).css() getter/setter that handles camelCase names, objects, automatic px units and removal.
22.How do you add, remove, and modify HTML elements using JavaScript?
createElement, append, replaceWith, remove, classList, fragments, templates and avoiding innerHTML XSS.
23.Describe event capturing in JavaScript and browsers
The top-down phase of DOM event propagation and when listening in it is useful.
24.What are event listeners and how are they used?
addEventListener options (capture, once, passive, signal), removal and memory hygiene.
25.How do you manipulate CSS styles using JavaScript?
Classes, custom properties, inline styles, computed styles and constructable stylesheets.
26.What is the difference between `mouseenter` and `mouseover` event in JavaScript and browsers?
Why mouseenter does not bubble or fire for children, and when each is the right choice.
27.How do you prevent the default behavior of an event?
preventDefault, cancelable events, passive listeners and when not to block defaults.
28.Explain the difference between `document.querySelector()` and `document.getElementById()`
Selector power vs a direct id lookup, scoping, live vs static collections and escaping.
29.Explain the concept of `this` binding in event handlers
this as currentTarget in listeners, arrows and bind, removing bound listeners and handleEvent objects.
30.What is the DOM and how is it structured?
The live tree of nodes the browser builds from HTML, node types, and how it relates to rendering.
31.Hello World Counter
Build a counter with increment, decrement and reset that never drops below zero and announces its value.
32.Identical DOM Trees
Decide whether two DOM nodes are structurally identical: same tags, attributes, text and children, without using isEqualNode.
33.getElementsByStyle
Find descendant elements whose computed value for a CSS property equals a given value, normalising values like red vs #f00.
34.Explain the event phases in a browser
Capture, target and bubble phases, eventPhase values, and how shadow DOM retargeting fits in.
35.What is the difference between innerHTML and textContent?
How markup parsing, text nodes and innerText differ, and why textContent is the safe default.
36.Compare IntersectionObserver, ResizeObserver and MutationObserver. When would you use each?
What each observer watches, when callbacks run, performance characteristics and common pitfalls.
37.When should you virtualise a long list, how does it work, and what does it cost you?
Windowing mechanics, variable heights, accessibility and find-in-page trade-offs, and alternatives like content-visibility.
38.What is the difference between `event.preventDefault()` and `event.stopPropagation()`?
Cancelling the browser action vs stopping the event travelling, plus stopImmediatePropagation.
39.What are React Portals used for?
Rendering into another DOM node while staying in the React tree for context and events.
40.What is the difference between the Window object and the Document object?
The global browsing-context object versus the DOM tree of the loaded page.
41.Dropdown Menu
Build an accessible menu button: open and close, arrow-key and typeahead navigation, outside click and focus return.