location is the owned property of window and document.
window.hasOwnProperty("location")
true
document.hasOwnProperty("location")
true
But when i tried to compare prototype of location with Location.prototype, i got error that Location is not defined.
Although i can see Location constructor in the Location object.
What is the prototype object of location?
Ideally we should be able to see Location.prototype and methods on it like assign and other two.
Chrome bug?
A prototype may not be visible, even if it's listed.
Try this :
var a = (function(){ // this is a closure protecting A
var A = function(b){
this.b = b;
}
return new A('test');
})();
console.log(a); // logs ▸A
console.log(A); // error, as A isn't defined
There is no reason for the browser to make Location
visible. And certainly no reason for it to clutter the global namespace.
w3 calls the location object an "interface", see http://www.w3.org/html/wg/drafts/html/master/browsers.html#location so it is propably no goot idea to extend the prototype of it.
Why do you want to extend the prototype of Location? Is there a better way to solve your origin problem?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With