BOM (Browser Object Model)

Expert-Level Explanation
The Browser Object Model (BOM) in JavaScript is used to interact with the browser. It includes objects like window
, which represents the browser window, andlocation
, which represents the URL. You can use BOM to get details about the screen, redirect the browser to another URL, and more.
Creative Explanation
The BOM is like the control panel of a spaceship (the browser). From this panel, you can see and control where the spaceship is going (location
), look out of different windows (window
), and control the size and position of these windows.
Practical Explanation with Code
window.alert('Hello, world!'); // Opens an alert box
console.log(location.href); // Prints the current URL to the console
window.resizeTo(600, 400); // Resizes the browser window
Real-world Example
Using the BOM is like being a pilot in an aeroplane cockpit, where you have control over the navigation systems (location
), can look through different windows (window
), and have various controls and instruments at your disposal.
Subscribe to my newsletter
Read articles from Akash Thoriya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Akash Thoriya
Akash Thoriya
As a senior full-stack developer, I am passionate about creating efficient and scalable web applications that enhance the user experience. My expertise in React, Redux, NodeJS, and Laravel has enabled me to lead cross-functional teams and deliver projects that consistently exceed client expectations.