zoukankan      html  css  js  c++  java
  • ES6笔记02-箭头函数

    eg1:
    //
    ES5 匿名函数 var total = values.reduce(function (a, b) { return a + b; }, 0); // ES6 匿名函数 var total = values.reduce((a, b) => a + b, 0);

    eg2:

    // ES5  匿名函数
    var selected = allJobs.filter(function (job) {  
      return job.isSelected();  
    });  
      
    // ES6  匿名函数
    var selected = allJobs.filter(job => job.isSelected());  
     // ES5  
    $("#confetti-btn").click(function (event) {   
      playTrumpet();  
      fireConfettiCannon();  
    });  
    // ES6  
    $("#confetti-btn").click(event => {  
      playTrumpet();  
      fireConfettiCannon();  
    });  

    普通函数与箭头函数有个微小的不同点。箭头函数没有自己的this值,其this值是通过继承其它传入对象而获得的。

  • 相关阅读:
    Skimage=scikit-image SciKit 包的模块(转载)
    python day12
    python day11
    python day10
    python day9
    python day8
    python day7
    python day6
    python 第五天
    python 第四天
  • 原文地址:https://www.cnblogs.com/qing619/p/6197895.html
Copyright © 2011-2022 走看看