JavaScript Learning Notes (v) _javascript tips

Source: Internet
Author: User
Local objects
①array class
②date class

object's type Built-in object
①global objects
②math objects

Host Object
Today continue to learn the objects in JS, the built-in object global object and the Math object yesterday, continue today.

Host Object
All Non-local objects are host objects host object, that is, the host environment provided by the ECMAScript implementation. All BOM and Dom objects are host objects, which are discussed in later chapters. -_-|||

Scope
There is only one scope----public scope in JS, and all properties and methods of all objects are public. Many developers have put forward an effective attribute scoping mode on the Internet, which solves the problem of ECMAScript. Because of the lack of a private scope, developers have developed a protocol that sets the attribute name to be underlined before and after. Remember, these underscores do not change the fact that these properties are public properties, it simply tells other developers that the attribute should be considered private. Some developers also like to use a single underline to explain private members.

Keyword this
The keyword this always points to the object that called the method, the current service object.

Why should I use it?

Because at the time of development do not know what the object of the call to the method is exactly what kind of a variable name, all use this. (There are many objects that call the same method)


If you do not use the object or this keyword to refer to a variable, ECMAScript it as a local variable or a global variable. The function will then look for a local or global variable named color, but will not find it, and what is the result? The function will display "NULL" in the warning.


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.