Learn JavaScript
❯ browser_dom.bom

window, location, history & navigator in JavaScript

$concept

Beyond the DOM sits the BOM (Browser Object Model): window (globals, sizing, dialogs, open/close), location (URL parts plus assign/replace/reload navigation), history (back/forward/go plus pushState for SPA routing), and navigator (language, onLine, clipboard, geolocation behind permissions).

location.assign navigates keeping history; replace swaps without an entry (login redirects); reload refreshes (true once forced server). history.pushState plus popstate handling implements client-side routing β€” the SPA navigation contract in two APIs.

$how it works
1

window hosts globals

Dimensions (innerWidth/Height), dialogs (alert/confirm β€” blocking, avoid), open/close, and every global binding.

2

location navigates

location.href reads/sets the URL; assign() keeps history, replace() swaps it, reload() refreshes.

3

history routes SPAs

pushState({}, "", "/page") changes URL without loading; popstate events drive back/forward handling.

4

navigator describes

language, onLine, clipboard (async, permissioned), geolocation (permissioned) β€” capability and context APIs.

$example
console.log(location.hostname);
history.pushState({}, "", "/learn");
console.log(location.pathname);
Output
(current hostname, then /learn without reloading)
1hostname reads the current host portion of the URL.
2pushState swaps the path client-side β€” address bar updates, no network happens.
3pathname confirms /learn β€” SPA navigation without a page load.
$use cases
SPA routing with pushState plus popstate handling
Post-login redirects via replace (no back-button return)
Locale and connectivity adaptation through navigator
Query parsing via URLSearchParams on location.search

Recommended resourcesAffiliate links Β· may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice β€” pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from β€” great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in JavaScript yourself β€” building beats watching.