2.ES6 compare a number of different ES5

ECMAScript 6

  ECMAScript 6 (hereinafter referred to as ES6) is the next generation standard JavaScript language, has been officially released in June 2015.

  Mozilla Corporation will be based on this standard, the introduction of JavaScript 2.0.

  ECMAScript and JavaScript, in the end what is the relationship? Many beginners will feel confused, simply,

  ECMAScript is the international standard JavaScript language, JavaScript is the realization of ECMAScript.

  Its goal is to enable JavaScript language can be used to write large complex applications, enterprise-class development language.

 

Contrast look at the difference between the ES5 and ES6

1. Declare Variable Scope

  Global variables declared in es5

    

  Var variable declaration in the presence of es5 coverage phenomenon

    

          return              

 

  es6 let in variable declarations are local scope


      

 

    es6 in const declaration is constant, the statement can not be modified once

    

 

   Returned an error: Constants can not be changed Uncaught TypeError: Assignment to constant variable.  

 

 2. template string

   es5 - very complicated, a bunch of symbols splicing

    

  es6 - Anti quotes can be resolved

    

  

3. function point

  es5   pointers to functions is the current object

    

     

     

 

    Arrow pointing function is windows, and arguments can not be used

     

 

    

     

 

    So if in the actual production, a function of the change point occurs, there is often inconvenient, so there is another way to create

      1 "Create a literal way:

        

        Back to Results

        

        2 "monomer mode:

          

          return

           

 

4. Create Object

  es5 create objects, tedious, poor readability

 

    

  

  Es6 create objects in the way, using the concept of class Class

       

 

  

 

Guess you like

Origin www.cnblogs.com/sunny666/p/11078094.html