首页 > 其他 > 详细

【ES6】箭头函数

时间:2016-09-08 14:32:25      阅读:102      评论:0      收藏:0      [点我收藏+]
let getPrices = () => 4.55
console.log(getPrices())

let arr = [‘apple‘, ‘banana‘, ‘orange‘]
arr.forEach(value => {
    console.log(value)
})
arr.forEach((value, index) => {
    console.log(value, index)
})

function Person() {
  var self = this;
  self.age = 0;

  setInterval(function growUp() {
    self.age++;
  }, 1000);
}

function Person(){
  this.age = 0;

  setInterval(() => {
    // this 指向 person 对象
    this.age++;
  }, 1000);
}

var person = new Person();

 

【ES6】箭头函数

原文:http://www.cnblogs.com/jzm17173/p/5852768.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!