JavaScript

JavaScript

By DeepSource

Null comparisons without type-checking operators may not work as intended JS-0059

Bug risk Autofix

Comparing to null without a type-checking operator (=== or !==), can have unintended results as the comparison will evaluate to true when comparing to not just a null, but also an undefined value.

Bad Practice

if (flag == null) {
  change();
}

while (isSet != null) {
  handle();
}

Recommended

if (flag === null) {
  change();
}

while (isSet !== null) {
  handle();
}