JavaScript

JavaScript

Made by DeepSource

Found trailing undefined in function call JS-W1042

Anti-pattern
Minor
Autofix

When an argument is omitted from a function call, it will default to undefined. It is therefore redundant to explicitly pass an undefined literal as the last argument.

Bad Practice

function hasOptionalParam(a: number, b?: number) {
  // ...
}

hasOptionalParam(1, undefined)

Recommended

function hasOptionalParam(a: number, b?: number) {
  // ...
}

hasOptionalParam(1)
hasOptionalParam(1, 2)