Alert (typeof a);//undefined a = function () { var a = ' 2 '; return A; }; Alert (typeof a);//function alert (typeof A ());//number
2, instanceof
var obj = {Obj:1}; Alert (obj instanceof Object);//true
var num = 1;alert (num instanceof number);//false
The values of all reference types are instances of object, so the instanceof operation conforms to always return true when the reference type value and the object constructor are detected. Returns False if it is used to detect the base type value. Because the base type is not an object.
Execution Environment and scope
1, the implementation of the environment is the most important concept of JS. Each environment can search up the scope chain, but any environment cannot enter another execution environment by searching down the scope chain.
2. Declaring variables
Variables declared with Var are automatically added to the nearest environment, and within the function, the closest environment is the function's local function. In the With statement, the closest environment is the function environment. If you initialize a variable without using the var declaration, the variable is automatically added to the global environment.
var o = function () { var a = ' 2 '; return A; }; Alert (typeof a);//undefined, there is no global access because it is defined inside a function, locally defined. Alert (typeof A ());//
var A; (function O () { a = ' 2 '; return A; } ()); Alert (typeof a);//string,a is not declared with Var, so it is automatically added to the global, so you can access a
Query identifiers
If no identifier is found, it is searched globally until a stop query is found
Chapter fourth variables, scopes and memory issues (II)