JS Window全局对象 [英] JS Window Global Object

查看:112
本文介绍了JS Window全局对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到Window Global Object是顶级对象。他是包含DOM,BOM和JS的所有代码的盒子。

I have learned that the Window Global Object is the top level Object. He is the "box" of all the codes its Contain the DOM,BOM,and The JS.

我已经知道窗口对象代表浏览器中的一个打开的窗口,以及window对象没有构造函数,这意味着我无法创建它的实例。

I have learned that the window object represents an open window in a browser, and also that the window object has no constructor which means I can't create its instance.

我已经知道该对象是由浏览器自动创建的。我想问的是怎么做?

I have learned that the object is automatically created by the Browser. What I wanted to ask is how?

我的意思是如果它没有构造函数,那么浏览器就无法为对象创建自己的实例。我当时认为浏览器必须能够以某种方式创建它,所以我的问题是浏览器是如何创建它的?如果有人能帮助我理解这一点,我会很高兴的。

I mean if it has no constructor, so the browser can't create its own instance to the object. I was thinking that the browser must be able to some way create it, so my question is how does the browser create it? I'll be happy if some one will help me to understand this.

推荐答案

没有构造函数?

>> window.constructor
[object Window]

嗯,你知道什么,构造函数!

Well, what do you know, a constructor!

那说......

>> new Window
(X) Object does not support this action

所以我想这只意味着本机代码可以创建Window的新实例。

So I guess that means only native code can create new instances of Window.

这篇关于JS Window全局对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆