本机对象和宿主对象之间有什么区别? [英] What is the difference between native objects and host objects?

查看:218
本文介绍了本机对象和宿主对象之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

后者是否只是引用由自定义构造函数创建的非原始函数对象(例如,var bird1 = new Bird();)?

Does the latter simply refer to nonprimitive function objects that were created by a custom constructor (e.g., var bird1 = new Bird();)?

推荐答案

这两个术语都在ECMAScript规范中定义:

Both terms are defined in the ECMAScript specification:


原生对象


$ b ECMAScript实现中的$ b

对象,其语义完全由
定义,而不是由主机环境定义。

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.

来源: http://es5.github.com/#x4.3.6

主机环境提供的对象,用于完成ECMAScript的
执行环境。

host object

object supplied by the host environment to complete the execution environment of ECMAScript.

注意任何非本机对象都是宿主对象。

NOTE Any object that is not native is a host object.

来源: http://es5.github.com/#x4.3.8

一些例子:

原生对象:对象(构造函数),日期数学 parseInt eval ,字符串方法如 indexOf replace ,数组方法,...

Native objects: Object (constructor), Date, Math, parseInt, eval, string methods like indexOf and replace, array methods, ...

主机对象(假设浏览器环境):窗口文档 location history XMLHttpRequest setTimeout getElementsByTagName querySelectorAll ,...

Host objects (assuming browser environment): window, document, location, history, XMLHttpRequest, setTimeout, getElementsByTagName, querySelectorAll, ...

这篇关于本机对象和宿主对象之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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