箭头函数,就是函数的简写:
如果只有一个参数,() 可以省;
如果只有一个return,{ }可以省。
实例说明:
let show1 = function () {
console.log('abc')
}
let show2 = () => {
console.log('abc')
}
show1() // abc
show2() // abc
let show4 = function (a) {
return a * 2
}
let show5 = a => a * 2 //简洁,类似python lambda 函数
console.log(show4(10)) //20
console.log(show5(10)) //20