使用rest参数代替“ arguments”(prefer-rest-params)

be-*_*ied 2 ecmascript-6

我无法解决这种情况-linter向我提出了其他解决方案。这是我的原始代码:

if (arguments[0] && typeof arguments[0] === 'object') {
  this.options = extendDefaultProperties(defaultProperties, arguments[0]);
}
Run Code Online (Sandbox Code Playgroud)

有什么帮助吗?先感谢您。

Ori*_*ori 5

使用rest参数参数收集到数组中args

demo(...args) {
  if (typeof args[0] === 'object' && args[0] !== null) {
    this.options = extendDefaultProperties(defaultProperties, args[0]);
  }
}
Run Code Online (Sandbox Code Playgroud)