之间有什么区别:
const MY_CONST = ()=>()
和
const MY_CONST = ()=>{}
?。谢谢。
答案 0 :(得分:2)
const MY_CONST = () => {}
语法与const MY_CONST = function() { }
非常相似。
() => ()
被称为对象文字表达式,用于返回一个对象,如下例所示:
const MY_CONST = params => ({foo: bar})
在此处查看更多详情: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions
https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/