📍 Location Object
Last Updated: 26th October 2025
The Location Object provides information about the current URL of the browser and allows you to redirect or reload the page.
It is a property of the window object (window.location).
Hinglish Tip 🗣: location object browser ke current page ke “address (URL)” ke saare parts batata hai — aur tum chaho to use badal bhi sakte ho!
Common Properties
Common Methods
Example
console.log("Full URL:", location.href);
console.log("Host:", location.host);
console.log("Pathname:", location.pathname);
console.log("Protocol:", location.protocol);
console.log("Search Params:", location.search);
// Redirect example
// location.assign("https://www.google.com");
// Reload example
// location.reload();
