本机对象和宿主对象之间有什么区别

本机对象和宿主对象之间有什么区别

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

问题描述

后者是否只是引用由自定义构造函数创建的非原始函数对象(例如,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:

注意标准本机对象是定义的在本说明书中。一些
本机对象是内置的;其他可能是在
执行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.

来源:

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

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

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

来源:

一些例子:

原生对象:对象(构造函数),日期数学 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, ...

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

08-13 05:32