๐Ÿ“– Introduction to Window, BOM, and DOM in JavaScript

๐ŸŒ๐ŸชŸ๐ŸŒณWindow, BOM, and DOM in JavaScript



In JavaScript, window, BOM (Browser Object Model), and DOM (Document Object Model) are distinct but related concepts, all playing a crucial role in web development. window object.


1๏ธโƒฃ Big Picture (Hierarchy)



  • ๐ŸชŸ Window : The global container object in the browser that holds everything (BOM + DOM)
  • ๐ŸŒ BOM (Browser Object Model) : The browser environment (history, location, navigator, screenโ€ฆ) โ†’ Represents the browser environment around the page.
  • ๐ŸŒณDOM (Document Object Model) : The structured representation of the webpage (HTML) โ†’ Represents the page content (HTML).

Hierarchy :

๐ŸชŸWindow
  โ†ณ ๐ŸŒBOM (browser features: navigator, screen, location, history, document)
  โ†ณ ๐ŸŒณDOM (page structure, HTML content via document)

In summary, the window object is the top-level object in the browser environment. The BOM extends the window object to provide control over the browser itself, while the DOM is a subset of the BOM (accessed via window.document) that specifically deals with the content and structure of the web page.

Window โ†’ BOM + DOM

  • Window ๐ŸชŸ = The global container object.
  • BOM ๐ŸŒ = Part of the Window, represents the browser environment (navigator, location, history, screen).
  • DOM ๐ŸŒณ = Also part of the Window, represents the web page content (document).

So the proper way to describe it is:
Window โ†’ BOM
Window โ†’ DOM


Interconnections Between Window, DOM & BOM


๐Ÿ”น Window โ†’ The parent of everything.

๐Ÿ”น BOM โ†’ Browser control system inside the Window.

๐Ÿ”น DOM โ†’ Webpage structure inside the Window.

๐Ÿ”น Both BOM and DOM are accessible via Window, but they serve different roles โ€”
BOM for browser features ๐Ÿงญ, and DOM for page manipulation ๐Ÿงฑ.


Understanding the difference between them is essential to becoming a skilled JavaScript developer.


Complete and Continue  
Discussion

4 comments