在网络浏览器中,是Window对象本地的ECMAScript对象吗? [英] In web-browsers, is the window object a native ECMAScript object?

查看:120
本文介绍了在网络浏览器中,是Window对象本地的ECMAScript对象吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ECMAScript规范定义了一个 控制进入任何执行上下文之前创建独特的全球目标。这个全局对象是内置的ECMAScript对象的标准,因此,原有的对象。

The ECMAScript specification defines an "unique global object that is created before control enters any execution context". This global object is a standard built-in object of ECMAScript, and therefore a native object.

该规范还规定:

在除了本说明书中的全局定义的属性
  对象可能有额外的主机定义的属性。这可以包括
  属性,其值是全局对象本身;例如,在
  HTML文档对象模型中的窗口全局对象的属性
  全局对象本身。

In addition to the properties defined in this specification the global object may have additional host defined properties. This may include a property whose value is the global object itself; for example, in the HTML document object model the window property of the global object is the global object itself.

所以,在网络浏览器中,窗口对象仅仅是ECMAScript的全局对象一个方便的名称,因此,在窗口对象是土生土长的ECMAScript对象。

So, in web-browsers, the window object is just a convenient name for the ECMAScript global object, and therefore, the window object is a native ECMAScript object.

我没有得到这是否正确?

Did I get this correctly?

推荐答案

这主要归结于它真正的意思是本地对象或宿主对象的问题。 ECMAScript规范提供了这些术语相当抽象定义,并且有足够的空间,不同的定义间pretations。例如,在原生对象的定义,什么是语义这个词实际上是在谈论。难道只是(由[[作为propName]]内部属性中指定的ES)原始对象语义或它包括对象的应用程序级别的语义。在DOM窗口对象肯定有未在ES规范中定义的可观察到的应用程序级传递,如果那些语义认为这不可能是一个原生对象。

This mostly comes down to a question of what it really means to be a "native object" or a "host object". The ECMAScript specification provides fairly abstract definitions of those terms and there is plenty of room for differing interpretations of the definitions. For example, in the definition of native object, what is the word "semantics" actually talking about. Is it just the primitive object semantics (in ES specified by the [[propName]] internal properties) or does it include application level semantics of the object. The DOM window object certainly has observable application level semantics that are not defined in the ES specification, so if those semantics are considered it can't be a "native object".

答案很可能是更简单,如果你把它看作是实现语用学的问题。一个ES引擎的实现可能认为,在ES堆中分配和管理的ES垃圾收集器是一个原生ES对象的对象。 宿主对象一般会被认为是东西存在外部的ES堆和正在使用某种形式的互操作层的,如COM,XPCOM或嵌入V8 API来访问。根据不同的实现,DOM窗口对象可能掉入任何一类。这种区别可能是更相关的两台发动机实施者和主机商比任何规格级别区分。

The answer is probably much simpler if you look at it as a question of implementation pragmatics. A ES engine implementer probably thinks of any object that is allocated in the ES heap and managed by the ES garbage collector to be a "native ES object". A "host object" would generally be thought of something that exists external to the ES heap and that is accessed using some sort of interoperability layer such as COM, XPCOM, or the V8 embedding API. Depending upon the implementation, the DOM window object might fall into either category. This distinction is probably more relevant to both engine implementers and host providers than any of specification level distinctions.

有可能将在ES规范的下一个版本的定义进一步澄清。甚至有消灭本土和主机的对象术语的建议: HTTP ://wiki.ecmascript.org/doku.php ID =稻草人:术语。不过,目前尚不清楚这样的定义是否真的有非常实际的影响。

There will likely be further definitional clarifications in the next edition of the ES specification. There is even a proposal to eliminate the "native" and "host" object terminology: http://wiki.ecmascript.org/doku.php?id=strawman:terminology . However, it isn't clear whether such definitions really have very much practical impact.

这篇关于在网络浏览器中,是Window对象本地的ECMAScript对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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