Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between javascript host objects and built-in objects

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today Xiaobian to share with you the difference between javascript host objects and built-in objects, what are the relevant knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you read this article after harvest, let's learn about it together.

Differences: 1. Built-in objects are a subset of native objects belonging to native objects, while host objects are not native objects of the engine;2. Built-in objects are all objects provided by ECMAScript implementations independent of the host environment, while host objects are objects that are not officially defined by ECMAScript.

Operating environment of this tutorial: Windows 10 system, Javascript version 1.8.5, Dell G3 computer.

What is the difference between javascript host objects and built-in objects?

Native objects include built-in objects (objects created when JavaScript engine is initialized) and objects dynamically created during JavaScript running, while host objects are objects injected into JavaScript engine by JavaScript host environment (runtime environment) through some mechanism during JavaScript engine running.

Specific differences:

Build-in objects: objects that are always created during engine initialization, a subset of native objects. Built-in objects are those provided by EcmaScript that are independent of host objects, including Global and Math(numeric objects) and built-in objects.

Naïve objects: In addition to built-in objects, includes objects that are dynamically created during runtime. Native objects are independent of the host environment, including Object,Array,Function,Number,String,Date

Host objects: Host objects are not native objects of the engine, but objects registered into the JavaScript engine by the hosting framework through some mechanism. Javascipt's operating environment is the operating system and browser, including two types of host objects BOM and DOM

First, the original object

ECMA-262 defines native objects as "objects provided by ECMAScript implementations independent of the host environment."

Contains: Object, Function, Array, String, Boolean, Number, Date, RegExp, Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, ActiveXObject(server aspect), Enumerator(collection traversal class), RegExp (regular expression)

II. Built-in objects

ECMA-262 defines built-in objects as "all objects provided by ECMAScript implementations that are independent of the host environment and appear at the beginning of ECMAScript program execution." This means that the developer does not have to explicitly instantiate the built-in object; it is already instantiated.

Again,"independent of the host environment." ECMA-262 defines only two built-in objects, Global and Math (they are also native objects, each built-in object is native by definition)

III. Host object

What is a "host object"? The "host" in ECMAScript is, of course, the environment in which our web pages run, namely the "operating system" and the "browser."

BOM and DOM are host objects. Because it presents different content to different "host" environments. In fact, to put it bluntly, ECMAScript officially undefined objects belong to host objects, because most of the undefined objects are objects created by ECMAScript programs.

The above is "javascript host object and built-in object what is the difference" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 224

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report