Summary vue commonly used es6 syntax (reprint)

    1 , the wording object 
        es5 objects: {the Add: the Add, substrict: substrict} 
        : {the Add, substrict} ES6 objects

     2 written, the method in object 
        es5 objects: {the Add: function () {}, substrict : function () {}} 
        ES6 objects: {the Add () {}, substrict () {}}
    
     . 3 , the object derived wording 
     calc.js 

     ES5 two forms:
      . 1, module.exports = fucntion () {};
      2, exprots.add =   fucntion () {}; 

    ES6 the wording:
     . 1, Export default { 
        add () {} 
    }
     2 , Export fucntion add () {} the method as corresponds to add a property to exports objects hanging


     4 , imported objects 
    ES5: var= the require the Add ( './ calc.js' ); 
    ES6: 
    if you are exporting: Export default {the Add () {}} 
    Then by obj from Import './calc.js' 

    if you are exporting: 
// wording a 
    Export fucntion the Add () {} 
    Export fucntion substrict () {} 
    Export the PI const = 3.14   
 // writing two 
    var m =. 1 ; 
    Export m {}; 
// writing three 
   var firstName = 'Michael' ;
    var lastName = 'Jackson ' ;
    var year = 1958 ; 
   Export {firstName, lastName, year};

    Can then import {add, substrict, PI}-demand loading from './calc.js' 

    . 5 , the arrows written es6 function 
    evolution arrow: 
    @ Demand: using a function to realize the reverse order 
    [2,1, . 3] .sort ( function (X, Y) { return Y - X;}); 

    // implemented by arrow function => to read goes 
    [2,1, 3] .sort ((X, Y) => { return Y - X;}); 
    [ 2,1, 3] .sort ((X, Y) => {X ++; Y ++; Y - X;}); 
    [ 2,1, 3] .forEach (X => { console.log (x)});

 

 

Original Address: https://www.jianshu.com/p/b4d48e9846e7

Guess you like

Origin www.cnblogs.com/lgqing920/p/11464674.html