es6-箭头函数-没有重复的命名参数

es6- arrow function- no duplicate named arguments

我不太理解箭头函数的最后几种方式:

No duplicate named arguments- arrow functions cannot have duplicate named arguments in strict or nonstrict mode, as opposed to nonarrow functions that cannot have duplicate named arguments only in strict mode.

以上段落摘自 Nicholas C. Zakas 所著书籍 "Understanding ECMAScript 6" 的 'Function' 章。

根据上面的描述,我知道箭头函数不像其他函数那样没有参数。

前半句我能看懂,但后半句开头是"as opposed to..."。

什么意思"nonarrow functions that cannot have duplicate named arguments only in strict mode."

其实严格模式下的函数也是有参数的。我不知道作者的意思。

表示以下有效JavaScript:

function bar(foo, foo){}

然而,当使用严格模式时不是:

'use strict';
function bar(foo, foo){}
// SyntaxError: duplicate formal argument foo

对于箭头函数,无论是严格模式还是非严格模式,重复的命名参数总是无效的。

(foo, foo) => {}
// SyntaxError: duplicate argument names not allowed in this context

According to description above, I know that arrow function has not arguments like other function.

不确定您是否理解正确。箭头函数可以有参数,只是没有arguments.