javscJavaScript Browser BOM (Browser Object Model): An Overview
The Browser Object Model (BOM) in JavaScript refers to the set of objects provided by the browser to interact with the browser environment outside of the webpage’s content. While the Document Object Model (DOM) handles the content of a webpage, the BOM allows developers to control the browser itself.
Key Components of BOM
window
Object
The global object representing the browser window. All BOM properties and methods are accessed throughwindow
.
Example:
console.log(window.innerWidth); // Width of the browser's viewport
alert("Hello, BOM!"); // Displays an alert box
2. navigator
Object
Provides information about the browser and operating system.
Example:
console.log(navigator.userAgent); // Details about the browser and OS
console.log(navigator.language); // Language setting of the browser
3. screen
Object
Gives information about the user's screen properties, such as resolution and color depth.
Example:
console.log(screen.width); // Width…