The inequality operator should be preferred over negating the equality comparison result

  • Code Quality
  • Low
  • No tags

This rule applies when the logical negation operator is used on the equality comparison result.

The inequality operator (!==, !=) gives the same result as applying the negation operator (!) to the equality (===, ==) comparison result. Therefore, it is recommended to use the inequality operator because it is simpler and easier to understand.

Noncompliant Code Example

View with compliant examples side by side
if (!(a === b)) { // PREFER_INEQUALITY_OPERATOR alarm

Compliant Code Example

View with noncompliant examples side by side
if (a !== b) {


This rule was introduced in DeepScan 1.25.0.


Was this documentation helpful?