Location对象的原型对象是什么?

P K*_*P K 5 javascript prototype

location是窗口和文档的拥有属性.

window.hasOwnProperty("location")
true

document.hasOwnProperty("location")
true
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试将Location的原型与Location.prototype进行比较时,我得到的错误是Location未定义.

虽然我可以在Location对象中看到Location构造函数.

位置的原型对象是什么?

理想情况下,我们应该能够看到Location.prototype和方法,如assign和其他两个.

Chrome bug? 在此输入图像描述

Den*_*ret 4

即使列出了原型,它也可能不可见。

\n\n

尝试这个 :

\n\n
\xe2\x80\x8bvar a = (function(){ // this is a closure protecting A\n    var A = function(b){\n        this.b = b;\n    }\n    return new A('test');\n})();\nconsole.log(a); // logs \xe2\x96\xb8A\nconsole.log(A); // error, as A isn't defined\n
Run Code Online (Sandbox Code Playgroud)\n\n

浏览器没有理由使其Location可见。当然,它没有理由让全局命名空间变得混乱。

\n