JavaScriptStudy Notes (5)
① Array class
Local object
② Date class
① Global Object
Object Type built-in object
② Math object
Host Object
Continue to learn about objects in JS today, Global objects and Math objects built in yesterday, and continue today.
Host Object
All non-local objects are host objects, that is, objects provided by the host environment implemented by ECMAScript. All BOM and DOM objects are host objects, which will be discussed in later sections. -_-|
Scope
In JS, there is only one type of scope-Public scope. All attributes and methods of all objects are public. Many developers have put forward effective attribute scope models on the Internet to solve this problem of ECMAScript. Due to the lack of private scopes, developers have developed a protocol to underline the attribute names. Remember, these underscores do not change the fact that these attributes are public properties. They only tell other developers that they should regard this property as private. Some developers also like to use single underscores to indicate private members.
Keyword: this
This keyword always points to the object that calls this method, the current service object.
Why?
Because during development, I don't know what kind of variable name the object that calls this method is, and all use this. (When many objects call the same method)
If you do not use an object or the keyword this to reference a variable, ECMAScript regards it as a local variable or a global variable. Then this function will find the local or global variable named color, but it will not find it. What is the result? This function will display "null" in the warning ".
9-12-30