Episode 1 — Fundamentals / 1.16 — Using Browser Functionalities in JavaScript
1.16.a — Browser Object Model (BOM)
In one sentence: The BOM is the set of browser-provided objects rooted at
window—navigator,location,history, anddocument— that let JavaScript interact with the browser chrome, environment, and navigation, alongside the DOM.
Navigation: ← 1.16 Overview · 1.16.b — Location & History →
1. BOM vs DOM
| DOM | BOM | |
|---|---|---|
| Standard | W3C / WHATWG — document structure | Mix of WHATWG HTML + legacy de-facto APIs |
| Core object | document (tree of nodes) | window (global object + browser services) |
| Typical use | Read/change page content | Navigate, resize, timers, alert, storage, geolocation… |
document lives on window: window.document === document in pages.
2. window
- Global object in browsers — top-level
var/functiondeclarations becomewindowproperties (non-strict legacy); globallet/constdo not. window.innerWidth/innerHeight— viewport size.window.scrollY,scrollTo()— scrolling.window.setTimeout/setInterval— timers (also global withoutwindow.).window.location,window.history,window.navigator— shortcuts to sub-objects.
3. navigator
Information about the browser and runtime — not for “sniffing” security decisions alone.
| Property / method | Use |
|---|---|
navigator.userAgent | String identifying browser/engine (fragile for feature detection) |
navigator.language, languages | Locale preferences |
navigator.onLine | Rough network connectivity hint |
navigator.clipboard | Clipboard API (permissions-gated) |
navigator.geolocation | Location (user permission) |
Prefer feature detection (if ('geolocation' in navigator)) over parsing userAgent.
4. history
Represents the session history stack for the tab — back/forward list (see 1.16.b).
5. location
window.location (same as document.location in modern browsers) — current URL, protocol, host, path, query, hash — and methods to navigate or reload (see next lesson).
6. document
The DOM root — elements, events, creation APIs. Covered in 1.14; here it sits in the BOM mental map as the bridge from window to the page tree.
7. Key takeaways
windowis the global browser hub;documentis the DOM entry.navigatordescribes environment and optional device APIs.location+historycontrol where the user is in URL space and time (navigation stack).
Explain-It Challenge
Explain without notes:
- What is one capability
windowprovides thatdocumentdoes not? - Why is
navigator.userAgentalone a weak way to decide if a feature exists? - How are
locationandhistorydifferent in one sentence each?
Navigation: ← 1.16 Overview · 1.16.b — Location & History →