New:Embedded & IoT Bootcamp
Tutorial 1 of 11 in series

Browser Environment & Specs

Understand the JavaScript browser environment - window, DOM, BOM, and ECMAScript

Abhishek Sharma 2026-06-10 Web Development / Frontend / JavaScript DOM / Document
9%

The JavaScript Browser Environment

When JavaScript runs in a browser, it gets access to a special environment with three main parts:

  • ECMAScript - the core language (variables, functions, loops, etc.)
  • DOM (Document Object Model) - APIs to interact with HTML/XML pages
  • BOM (Browser Object Model) - APIs to interact with the browser itself
┌─────────────────────────────────────┐
│           JavaScript                │
│  ┌──────────┐ ┌──────┐ ┌────────┐   │
│  │    JS    │ │ DOM  │ │  BOM   │   │
│  │ Language │ │ APIs │ │ APIs   │   │
│  └──────────┘ └──────┘ └────────┘   │
└─────────────────────────────────────┘

The Global Object: window

In a browser, window is the global object. Every global variable, DOM API, and BOM method lives on it:

Demo: The window object
HTML
<p id='output'></p>
JavaScript
const out = document.getElementById('output');
out.innerHTML = 'Window inner width: ' + window.innerWidth + 'px<br>';
out.innerHTML += 'Page location: ' + window.location.href;
Live Output Window

DOM vs BOM

DOM BOM
Document Object Model Browser Object Model
document.getElementById() navigator.userAgent
document.querySelector() location.href
Access/manipulate page content Access/manipulate browser
Standardized by W3C Partly standardized (HTML spec)

DOM Specs

The DOM is maintained by the W3C and WHATWG. Modern browsers implement the DOM Living Standard which includes:

  • Core DOM - the tree structure model
  • HTML DOM - HTML-specific elements and attributes
  • CSSOM - CSS object model for styling

BOM APIs

The BOM provides browser-level objects:

  • navigator - browser info (user agent, geolocation, media devices)
  • location - URL information and navigation
  • history - session history (back, forward, pushState)
  • screen - screen dimensions
  • fetch / XMLHttpRequest - network requests
  • localStorage / sessionStorage - client-side storage
Demo: BOM APIs in action
HTML
<p id='bom-output'></p>
JavaScript
const el = document.getElementById('bom-output');
el.innerHTML = 'Browser: ' + navigator.userAgent + '<br>';
el.innerHTML += 'Platform: ' + navigator.platform + '<br>';
el.innerHTML += 'Screen size: ' + screen.width + 'x' + screen.height;
Live Output Window

Key Takeaways

  • JavaScript in the browser has three layers: language, DOM, BOM
  • window is the global object - all browser APIs hang off it
  • DOM lets you read and modify the page
  • BOM lets you interact with the browser itself
  • Both DOM and BOM are evolving standards - always check compatibility

Keep learning

Related tutorials from across the library.

All tutorials
Tutorial2026-06-10

DOM Tree

Understand the DOM tree - how browsers represent HTML as a document tree

Web Development / Frontend / JavaScript DOM / Document

JavaScriptDOM
Tutorial2026-06-10

Walking the DOM

Navigate the DOM tree using parent, child, and sibling properties

Web Development / Frontend / JavaScript DOM / Document

JavaScriptDOM
Tutorial2026-06-10

Searching Elements

Find DOM elements using getElement*, querySelector*, and more

Web Development / Frontend / JavaScript DOM / Document

JavaScriptDOM