Virtual DOM in React
The real DOM is the browser tree. React keeps a virtual DOM — an in-memory description of UI. On state change it diffs the new tree with the previous one and patches only what changed (reconciliation). You think in components and state, not $('#x').text().
Don’t claim ‘virtual DOM is always faster than vanilla’. It’s faster than naive full innerHTML redraws and easier to reason about. Direct DOM APIs still win micro-benchmarks. Honesty scores.
Virtual DOM in React — output — render / diff / patch. You don’t edit document.getElementById for every click.
setState
│
▼
new virtual tree
│ diff
▼
patch real DOMExam tip
Diff + patch. Don’t oversell speed.