Ecmascript 1 (object type)

Source: Internet
Author: User

Ecmascript objects are mainly divided into two categories::

1. Local objects, that is, objects independent of the host environment.

 

Object fuction array string Boolean number date RegEx error evalerror rangeerror referenceerror typeerror urlerror syntaxerror

 

A special type of local object is built-in objects: Global and math.

Ecmascript does not exist in independent functions. All function pairs must rely on objects.

Global Objects have functions such as encodeurl (), decodeurl (), and eval.

Note: Each defined global variable points to the global object, and the window object also points to the global object,Global variables are applied to allCodeShared, so it is easy to cause name conflicts between different pages. To write code, you should reduce the definition of global variables..

FunctionSum (x, y ){//Antipattern: Implied globalResult = x +Y;ReturnResult ;}

The result in the above function is defined as a global variable.

 
FunctionSum (x, y ){VaRResult = x +Y;ReturnResult ;}

View code

Use VaR to define result as a local variable.

In addition, the global variables created through var Declaration are different from those implicitly created through var declaration:

The global variables created through var declaration cannot be deleted.

The globally variables created by implicit deletion can be deleted.

Returns true or false after the delete operator operation to identify whether the deletion is successful.

2. Host Object

There are two main categories: BOM and Dom.

 

 

 

 

 

 

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.