Scope, variable lift, lifting functions, data types

First, the scope of classification (variables defined within the scope range, can access the entire scope)

  1. The global scope

  (Not declared or not under strict mode) and the var declared variable defined outside a function, which is a global scope range, called global scope.

  2. Function scope

  And the var declared variables defined inside the function, whose scope is the whole range of functions, called function scope.

  3. Block scope (for ES6)

  Use let (const or constant) and declared in a brace (non-function) inside, which is within the range of the scope of this brace, called block scope.

Second, the variable lift (variable declarations will be raised to the top of the statement or function, location is also within the scope of its scope, let variable is not defined with the const variable lift)

Third, to enhance the function (function declarations will only enhance the function expression not improve)

  test () // normal execution

 

  function test () {}

  testOne () // testOne not a function

  was Testone = function () {}

Fourth, data types

  1. The six basic data types (undefined; null; boolean; number; string; symbol) is not able to new Boolean; new String; new Number (which is the type of object)

  2. Object (Array; Date; Math; RegExp; Function, etc.)

Guess you like

Origin www.cnblogs.com/shulan-hu/p/11479266.html