# The DOM and Browser APIs

> Understand what React does for you by manipulating the DOM directly, handling events and using storage and URL APIs. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/full-stack/dom-and-browser-apis
Last updated: 2026-11-28

Understand what React does for you by manipulating the DOM directly, handling events and using storage and URL APIs.

Beginner · about 6 hours · difficulty 2/5

Learn first: [JavaScript Fundamentals](https://www.internhack.in/roadmaps/tracks/full-stack/javascript-basics), [Semantic HTML](https://www.internhack.in/roadmaps/tracks/full-stack/html)

React hides the DOM, but it does not remove it. Knowing what happens underneath helps you debug rendering, events and performance.

### The DOM

The browser turns HTML into a tree of nodes. JavaScript can query nodes (querySelector), change text and attributes, add and remove elements, and toggle classes.

### Events

- addEventListener for click, input, submit and keydown.
- **Event bubbling** and **delegation**: one listener on a list instead of one per item.
- preventDefault on form submit so you can send data with fetch instead of reloading.

### Useful browser APIs

- **localStorage and sessionStorage**: small key-value storage. Never store auth tokens or secrets here.
- **URL and URLSearchParams**: read and build query strings for filters and pagination.
- **History API**: how client-side routers change the URL without reloading.
- **IntersectionObserver**: lazy loading and infinite scroll.

### Pitfalls

- Building large UIs with manual DOM updates. It quickly becomes unmanageable, which is exactly why React exists.
- Attaching listeners inside loops and never removing them.

You are ready to move on when you can build a small todo list in plain JavaScript that adds, completes and deletes items and persists them in localStorage.

## Key concepts

- **Selecting and updating elements**
- **Events and listeners**
- **Bubbling and delegation**
- **Form submit and preventDefault**
- **localStorage and sessionStorage**
- **URL and URLSearchParams**
- **IntersectionObserver**

## Mini project

Build a vanilla JavaScript expense splitter for a hostel trip: add expenses in rupees, assign who paid, show who owes whom, and save state in localStorage.

## Check yourself

You have a list of 500 items each needing a click handler. Why is event delegation a better choice than 500 listeners?

## Free resources

- [Document Object Model (DOM)](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model) (MDN)
- [Browser: Document, Events, Interfaces](https://javascript.info/ui) (javascript.info)
- [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) (MDN)

Previous: [JavaScript Fundamentals](https://www.internhack.in/roadmaps/tracks/full-stack/javascript-basics) · Next: [Asynchronous JavaScript and fetch](https://www.internhack.in/roadmaps/tracks/full-stack/async-javascript)

## More in JavaScript for the Whole Stack

- [JavaScript Fundamentals](https://www.internhack.in/roadmaps/tracks/full-stack/javascript-basics)
- [The DOM and Browser APIs](https://www.internhack.in/roadmaps/tracks/full-stack/dom-and-browser-apis)
- [Asynchronous JavaScript and fetch](https://www.internhack.in/roadmaps/tracks/full-stack/async-javascript)
- [npm, Packages and Build Tooling](https://www.internhack.in/roadmaps/tracks/full-stack/npm-and-tooling)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Full-Stack Developer Roadmap](https://www.internhack.in/roadmaps/tracks/full-stack)
