箭头函数几个模版例子
JavaScript Code复制内容到剪贴板
- // ES5
- var selected = allJobs.filter(function (job) {
- return job.isSelected();
- });
- // ES6
- var selected = allJobs.filter(job => job.isSelected());
- // ES5
- var total = values.reduce(function (a, b) {
- return a + b;
- }, 0);
- // ES6
- var total = values.reduce((a, b) => a + b, 0);
- // ES5
- $("#confetti-btn").click(function (event) {
- playTrumpet();
- fireConfettiCannon();
- });
- // ES6
- $("#confetti-btn").click(event => {
- playTrumpet();
- fireConfettiCannon();
- });
上一篇 keyup事件支持绑定未来元素
下一篇 css3球体旋转