Host Environment APIs

JavaScript's power in the browser comes from its ability to interact with the Host Environment. While the JS engine handles the logic, the browser provides a set of Web APIs that allow you to manipulate the page, handle events, and communicate with servers.


1. The DOM (Document Object Model)

The DOM is the programming interface for HTML and XML documents. It represents the page as a Tree Structure (the DOM Tree), where each node is an object representing a part of the document.


2. The BOM (Browser Object Model)

The BOM allows JavaScript to "talk" to the browser itself, beyond the contents of the page.


3. Storage and State

Browsers provide several ways to store data locally on the user's machine:


4. Modern Web Capabilities


Interview Pro-Tips: Event Delegation

A common interview question: What is event delegation?


Technical Summary

  1. DOM: The object representation of the page.
  2. BOM: Interaction with browser features like history and location.
  3. Concurrency: Web Workers provide a way to achieve multi-threading in the browser.