I. Javascript Core
1. Javascript type: two main types: original type and object type.
The original types include number, String, Boolean, null, and undefined. null and undefined are two special types.
- Typeof null = object, which indicates that null can be considered as a special object value, representing no object. Generally, null is considered as a separate member of a separate type, which can be the value of numbers, strings, and object, meaning no value;
- And typeof undefined === undefined. Undefined usually declares a variable, but does not pay the value for the variable. As a result, the variable value is undefined.
Object Type: Except for the preceding five primitive types, all objects are of the object type. Objects in JS are the set of attributes (JSON ).
2. Variables
Variables that are not declared using VAR are created as global variables.
4.3.1
JS does not have block-level scope. All variables declared in the function are defined in the function.
----------------------------------------------
Function Test (){
For (var k = 0; k <10; k ++ ){
Alert (k );
}
Alert (k); // 10
}
----------------------------------------------
VaR scope = "Global ";
Function f ()
{
Alert (scope); // undefined, not global
VaR scope = "local ";
Alert (scope );
}
F ();
----------------------------------------------
4.6.1
When the JS interpreter is running, a global object is created first. The attribute of the object is JSProgram.
4.6.2
JS functions run in their own execution environment. Has its own call object. The property of the called object is the local variable of the function.