GarrettZhang
1/20/2018 - 6:45 AM

箭头函数简写

function sayHello (name) {
  console.log('Hello', name);
}

setTimeout(function () {
  console.log('Loaded')
}, 2000)

list.forEach(function (item) {
  console.log(item)
})

// 简写
sayHello = name => console.log('Hello', name);

setTimeout(() => console.log('Loaded'), 2000);

list.forEach(item => console.log(item));