JavaScript advanced Programming--Chapter 4th: variables, scopes, and memory issues

Source: Internet
Author: User

4.1.4 Detection Type

Although TypeOf is the right hand when detecting a base data type, we do not want to know if a value is an object while detecting the value of a reference type, but want to know what type of object it is. The instanceof operator is provided for this ECMAScript:

Result=variable Instanceof Constructor

Ex:alert (Person instanceof object), alert (colors instanceof Array), alert (pattern instanceof REGEXP);

The value of all reference types is specified as an object instance.

typeof regular (different browsers will return function or object). ECMA-262 specifies that any object that implements the [call] method internally should return "function" when the typeof operation is applied.

4.2 Execution Environment and scope

The execution Environment (execution context) defines the other data that variables and functions have access to, determines their behavior, and each execution environment has a variable object associated with it (variable object), and all variables and functions defined in the environment are stored in the object. Although the code we write does not have access to this object, the parser uses it in the background when it processes the data. The global execution environment is one of the outermost execution environments. Depending on the hosting environment where the ECMAScript implementation resides, the objects that represent the execution environment are different. In a Web browser, the global execution environment is considered a Window object, so all global variables and functions are created as properties and methods of the Window object, and the code in an execution environment is executed, the environment is destroyed, All variables and function definitions stored therein are also destroyed (the global execution environment is not destroyed until the application exits).

JavaScript advanced Programming--Chapter 4th: variables, scopes, and memory issues

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.