
ES5
let show = function () {
console.log("show");
}
show()
ES6箭头函数
let show = () => {
console.log("show");
}
show()
当形式参数只有一个的时候,可以省略()
let arr = [1, 2, 3]
arr.forEach(v => {
console.log(v);
})
当代码只有一句话的时候,可以省略{},自动返回,return可以不写
let arr2 = arr.map(v => v + 10)
console.log(arr2);Share Your Experience
Post a Comment
Reader Discussion
0
No comments yet. Be the first to share your thoughts.