be-codified
be-codified

Reputation: 6144

Use the rest parameters instead of 'arguments' (prefer-rest-params)

I can not solve this case - linter points me to other solution. This is my original code:

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

Any help? Thank you in advance.

Upvotes: 23

Views: 27194

Answers (1)

Ori Drori
Ori Drori

Reputation: 192317

Use the rest parameters to collect the params into the array args:

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

Upvotes: 24

Related Questions