In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge points about the differences between host objects and native objects in javascript. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Difference: native objects are objects provided by the ECMAScript implementation independent of the host environment, that is, classes (reference types) defined by ECMA-262, while host objects are provided by the host environment implemented by ECMAScript, and all non-native objects are host objects.
The difference between built-in (Build-in) objects and native (Naitve) objects is that the former is always a subset of the engine initialization phase and is a subset of the latter, while the latter includes objects that are dynamically created during operation.
Engine extension objects are not a large collection, and it is generally certain that they are also native objects of the engine (but not native objects of the ECMA specification).
The host object is not a native object of the engine, but an object registered to the JavaScript engine by the host framework through some mechanism.
Some hosts refer to the objects / constructors they provide as "native objects". For example, Internet Explorer 7 calls the XMLHttpRequest () it provides native-as opposed to objects created by methods such as "new ActiveXObject ('Microsoft.XMLHTTP')" in earlier versions of it. In this case, the reader should note the difference between the "host's native object" and the "engine's native object".
1. Native object
ECMA-262 defines native objects (native object) as "objects provided by ECMAScript implementations independent of the host environment".
Object, Function, Array, String, Boolean, Number, Date, RegExp, Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, ActiveXObject (server side), Enumerator (collection traversal class), RegExp (regular expression)
As you can see, in a nutshell, a native object is a class (reference type) defined by ECMA-262.
Second, built-in objects
ECMA-262 defines built-in objects (built-in object) as "all objects provided by the ECMAScript implementation that are independent of the host environment and appear when the ECMAScript program starts execution." This means that developers do not have to explicitly instantiate the built-in object, it has been instantiated.
It is also "independent of the host environment". By definition, it seems difficult to distinguish between "built-in objects" and "native objects". ECMA-262 defines only two built-in objects, Global and Math (they are also native objects, and by definition, each built-in object is native).
So it's understandable. Built-in objects are a kind of native objects. Of the two objects it contains, the Math object is often used, but what is this Global object?
The Global object is the most special object in ECMAScript because it doesn't actually exist! In ECMAScript, there are no independent functions, and all functions must be methods of an object.
Similar to the isNaN (), parseInt (), and parseFloat () methods, they all appear to be functions, but in fact, they are all methods of the Global object. And the methods of the Global object are more than that.
III. Host object
What is "host object"? The "host" in ECMAScript is, of course, the environment in which our web pages run, that is, the "operating system" and "browser". All non-native objects are host objects (host object), which are provided by the host environment implemented by ECMAScript.
All BOM and DOM objects are host objects. Because it shows different content for different "host" environments. To put it bluntly, ECMAScript's officially undefined objects belong to host objects, because most of their undefined objects are objects created by themselves through ECMAScript programs. TML DOM is the W3C standard (abbreviation for HTML document object Model, Document Object Model for HTML).
HTML DOM defines a set of standard objects for HTML, as well as standard methods for accessing and processing HTML documents.
With DOM, you can access all HTML elements, along with the text and attributes they contain. You can modify and delete the contents, and you can also create new elements.
That's all of the article "what's the difference between host objects and native objects in javascript?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you 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: 0
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.