πŸ“– 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