什么是ECMAScript“原生对象”? [英] What is an ECMAScript "native object"?

查看:94
本文介绍了什么是ECMAScript“原生对象”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 ECMA-262 原生对象


ECMAScript实现中的对象,其语义完全是
,由此规范而不是主机环境定义

object in an ECMAScript implementation whose semantics are fully defined by this specification rather than by the host environment

内置对象定义为


提供的对象一个独立于
主机环境的ECMAScript实现,它出现在执行
ECMAScript程序的开始。

object supplied by an ECMAScript implementation, independent of the host environment, that is present at the start of the execution of an ECMAScript program.

带注释


本规范中定义了标准内置对象,
ECMAScript实现可以指定和定义其他
每个
内置对象都是本机对象。

如果本机对象是完全对象由ECMA-262规范而不是主机环境定义,ECMAScript实现可以指定和定义新的内置对象,如果这些新的内置对象未被ECMA完全定义,它们如何可以是本机对象 - 262规格?

If a native object is fully defined by the ECMA-262 specification rather than the host environment and an ECMAScript implementation may specify and define new built-in objects, how is it that these new built-in object's can be native objects when they are not fully defined by the ECMA-262 specification?

我缺少什么?

推荐答案

他们'重新原生,因为它们带有ECMAScript 实现。主机环境通常是由ECMAScript实现和其他几个协同工作的应用程序组成的应用程序。例如,

They're "native" because they come with the ECMAScript implementation. A host environment in generally an application consisting of an ECMAScript implementation and several other interfaces that work together. For instance,


  • 网络浏览器—主机环境由ECMAScript实现,DOM接口,渲染引擎,UI等组成。

  • Windows脚本宿主—主机环境由ECMAScript实现,VBScript实现等组成。

  • Node.js —由ECMAScript实现(V8),HTTP接口等组成的主机环境

  • Web Browser — a host environment consisting of ECMAScript implementation, DOM interface, Rendering engine, UI, etc.
  • Windows Script Host — a host environment consisting of ECMAScript implementation, VBScript implementation, etc.
  • Node.js — a host environment consisting of ECMAScript implementation (V8), HTTP interfaces, etc.

内置对象必需继承自对象功能,而主机对象—主机环境提供的对象,但不一定在执行开始时出现—不需要,但可能(有时也可以)。

"Built-in" objects are required to inherit from Object or Function, whereas host objects — objects provided by the host environment, but not necessarily present at the start of execution — are not required to but may (and sometimes do).


  • 对象()数组()日期( )

  • 数学 JSON ,全局对象。

  • Object(), Array(), Date()
  • Math, JSON, the Global object.
  • Mozilla's numerous JavaScript extensions — such as WeakMap() or __proto__
  • JScript's ActiveXObject() constructor and (undocumented) CollectGarbage() function

  • DOM对象, 文件窗口

  • console

  • DOM objects, document and window
  • console

这篇关于什么是ECMAScript“原生对象”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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