Browser Environment & Specs in JavaScript
JavaScript runs inside a browser environment, which provides various objects and APIs to interact with the web page and the browser itself.
🔹 1. The window Object
The window object is the global object in the browser. It represents the browser window and provides methods and properties to interact with it.
✔ Example: Accessing the window object
🔹 2. The navigator Object (Browser Info)
The navigator Object provides information about the browser and device.
✔ Example: Getting Browser Information
✔ Detecting if the user is on Mobile
🔹 3. The screen Object (Screen Info)
The screen object provides details about the user's screen.
✔ Example: Getting Screen Dimensions
🔹 4. The location Object (URL Info)
The location object provides details about the current page URL.
✔ Example: Getting the Current URL
✔ Redirecting to Another Page
✔ Reloading the Page
🔹 5. The history Object (Browsing History)
The history object allows interaction with the browser's history.
✔ Example: Navigating Back and Forward
✔ Moving to a Specific History Entry
⚠ Note: Due to security reasons, JavaScript cannot access the user's full browsing history.
🔹 6. The document Object (DOM Access)
The document object represents the webpage loaded in the browser.
✔ Example: Modifying Page Content
✔ Example: Selecting Elements
✔ Example: Changing Content Dynamically
🔹 7. Detecting Browser Features (Modernizr Alternative)
Instead of detecting browser types, it's better to check feature availability.
✔ Example: Checking for geolocation Support
✔ Example: Checking for Local Storage
🔹 8. The console Object (Debugging)
The console Object helps debug JavaScript.
✔ Example: Logging Different Messages
✔ Measuring Time for Execution
✔ Displaying Objects in a Table
🔹 Summary
| Object | Purpose | 
|---|---|
window | Global browser object | 
navigator | Browser & device info | 
screen | User's screen info | 
location | Current page URL details | 
history | Navigation history | 
document | DOM manipulation | 
console | Debugging tools | 
🚀 Use these browser objects to create dynamic and interactive web applications!

