Native objects, built-in objects, and host objects in JavaScript

Source: Internet
Author: User
Tags hosting

ECMA-262 defines local objects (native object) as "objects provided by ECMAScript implementations that are independent of the hosting environment."

It's a little bit dizzy to see that the definition is unclear, because the concept of "hosting environment" is not yet known as "hosting environment."

However, according to my strong literary foundation, the "host" refers to parasitic biological selection of the parasitic body, which reminds me of the "Fire Shadow" in the "white." Simply put, it is the user's machine environment, including the operating system and the browser.

Take a look at what "local objects" contains:

Object, Function, Array, String, Boolean, number, Date, REGEXP, Error, Evalerror, Rangeerror, Referenceerror, SyntaxError, TypeError, Urierror

As you can see, a local object is simply a class defined by ECMA-262 (reference type).

Built-in objects

ECMA-262 defines the built-in object (built-in object) as "all objects that are provided by the ECMAScript implementation, independent of the hosting environment, and appear when the ECMAScript program starts executing." This means that the developer does not have to instantiate the built-in object explicitly, it has been instantiated.

It is also "independent of the hosting environment". By definition, it seems difficult to distinguish between "built-in objects" and "local objects". ECMA-262 only defines two built-in objects, Global and Math (they are also local objects, by definition, each built-in object is a local object).

So it's understandable. Built-in objects are one of the local objects. The Math object we use often in the two objects that it contains, but what is the global object?

The global object is the most special object in ECMAScript because it doesn't exist at all, and it's a bit of a game. It is important to understand that in ECMAScript, there is no independent function, and all functions must be methods of an object.

Similar to the isNaN (), parseint (), and parsefloat () methods, and so on, all appear to be functions, and in fact, they are all methods of the global object. And the global object's approach is more than that. For the specific methods and properties of the global object, interested students can look at this: JavaScript Global object reference manual

Host Object

What is a "host object"? Mainly in this "host" concept, I have already introduced the "Fire Shadow", introduced the "white". The "host" in ECMAScript is, of course, the operating environment of our web page, which is "OS" and "browser".

All non-local objects are host objects (host object), which is the object provided by the hosting environment implemented by ECMAScript.

All BOM and Dom objects are host objects. Because it's different for different "hosting" environments. The truth is, ECMAScript, the official undefined object belongs to the host object, because most of its undefined objects are objects that are created by themselves through the ECMAScript program.

varOperson=NewObject;

Operson.name=' Simaopig ';

Operson. Age=' + ';

The object I define myself here Operson is the host object. Because this object is not defined in ECMAScript, this object only exists on the page that I am running. It seems to sound a philosophical proposition. It's strange that my theme doesn't have a del style.

Summarize

Local objects are those that are officially well-defined. A built-in object is a local object that contains only the global object and the Math object. The host objects are those that are not officially defined, and you build your own objects, plus DOM and BOM objects.

Transferred from: http://blog.csdn.net/zzjiadw/article/details/6881114

Native objects, built-in objects, and host objects in JavaScript (GO)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.