JavaScript & DOM โก Recently updatedUpdated on Jun 30, 2026 โ this content may still be evolving.
JavaScript DOM: Topics Not to Miss
Check off each topic before your interview.
DOM Tree Basics
- Document, Element, Node โ difference
-
document.getElementById,querySelector,querySelectorAll - When to use
getElementByIdvsquerySelector - Node types: Element (1), Text (3), Comment (8)
-
parentNode,children,firstElementChild,nextElementSibling -
childNodesvschildren(includes text nodes vs elements only)
Reading & Modifying DOM
-
textContentvsinnerHTMLvsinnerText -
setAttribute/getAttribute/dataset(data-*) -
classList.add,remove,toggle,contains -
styleproperty vsclassList(prefer classes) -
createElement,appendChild,insertBefore,remove -
DocumentFragmentfor batch inserts
Events
-
addEventListenervs inlineonclick - Event object:
targetvscurrentTarget - Bubbling vs capturing (3 phases)
-
stopPropagationvspreventDefault - Event delegation pattern
-
onceoption,{ passive: true }for scroll - Common events:
click,submit,input,keydown,change
Forms
-
formsubmit event andpreventDefault -
FormDataAPI - Input types and validation attributes
-
inputvschangeevents - Reading values:
value,checked,selectedIndex
Browser APIs
-
fetch+ JSON for API calls -
localStorage/sessionStorage -
JSON.parse/JSON.stringify -
setTimeout/setInterval/clearInterval -
window.location,history.pushState(SPA basics)
Performance & Best Practices
- Minimize DOM queries (cache selectors)
- Batch DOM updates (fragment,
display: nonetrick) - Reflow vs repaint (conceptual)
- Event delegation for dynamic lists
- Debounce for search inputs
Security Basics
- XSS risk with
innerHTMLand user input -
textContentfor user-generated text - CSP awareness (conceptual)
Module Organization
- Separating HTML, CSS, JS
- IIFE or ES modules for scope
- DOMContentLoaded vs script at end of body
Self-test: Can you build a todo list with add, delete, and filter in 30 minutes using only vanilla JS? If not, start mini-dom-challenges.md.