在ECMAScript中,一些本机对象如何内置? [英] In ECMAScript, how are some of native objects also built-in?

查看:61
本文介绍了在ECMAScript中,一些本机对象如何内置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为需要定义本机和内置对象才能回答这个问题。以下是ECMAScript规范定义的内容:

I suppose a definition of native and built-in objects is required to answer this question. Here's what the ECMAScript spec defines these as:


4.3.6原生对象

4.3.6 native object

ECMAScript实现中的对象,独立于主机环境,在
开始时出现ECMAScript程序的执行。

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

注意标准本机构建-in对象在此
规范中定义。 内置了一些原生对象;其他可能是在执行ECMAScript程序的过程中构建的

NOTE Standard native built-in objects are defined in this specification. Some native objects are built-in; others may be constructed during the course of execution of an ECMAScript program

4.3.7内置对象

由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实现可以指定和定义其他对象。每个
内置对象都是本机对象。 内置构造函数是一个
内置对象,它也是一个构造函数。

NOTE Standard built-in objects are defined in this specification, and an ECMAScript implementation may specify and define others. Every built-in object is a native object. A built-in constructor is a built-in object that is also a constructor.

我期待对这一个的解释。

I'm looking forward to an explanation of this one.

推荐答案

这是 ES5节目


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

4.3.6 native object # Ⓣ object in an ECMAScript implementation whose semantics are fully defined by this specification rather than by the host environment.

注意标准本机对象在本说明书中定义。一些本机对象是内置的;其他可能是在执行ECMAScript程序的过程中构建的。

NOTE Standard native objects are defined in this specification. Some native objects are built-in; others may be constructed during the course of execution of an ECMAScript program.

4.3.7
内置对象#Ⓣ
由对象提供ECMAScript实现,独立于主机环境,在ECMAScript程序执行开始时出现。

4.3.7 built-in object # Ⓣ 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实现可以指定和定义其他实现。每个内置对象都是本机对象。内置构造函数是一个内置对象,也是一个构造函数。

NOTE Standard built-in objects are defined in this specification, and an ECMAScript implementation may specify and define others. Every built-in object is a native object. A built-in constructor is a built-in object that is also a constructor.

正如你所看到的,它与你的不同之处在于已经显示。

As you can see, it's different that what you've shown.

内置对象是ECMAScript兼容引擎提供的本机对象。例如:

Built-in objects are native objects made available by the ECMAScript-compliant engine. For example:


  • 字符串

  • 对象

  • 数组

  • 未定义

  • 布尔

  • 等。

  • String
  • Object
  • Array
  • Undefined
  • Boolean
  • etc.

原生对象例如:

var obj = {};

或之前显示的列表。内置对象是原生的。

Or the list shown before. Built-in objects are native.

此外,您没有显示它,但主机对象是依赖于环境的对象。例如,在浏览器中, 主机对象是窗口。还有其他主机对象,例如 document XMLHttpRequest

Also, you didn't show it, but a host object is an object dependant on the environment. For example, in browsers, the host object is window. There are other host objects such as document or XMLHttpRequest though.

这篇关于在ECMAScript中,一些本机对象如何内置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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