Strict equality should not be used for two values with different types
- No tags
This rule applies when two values with different types are compared with strict equality.
Strict equality is always
false for different types, so this comparison is not likely to be a programmer's intent.
Noncompliant Code ExampleView with compliant examples side by side
var x = 10 / 3; var b = x.toFixed(1) === 3.3; // COMPARE_INCOMPATIBLE_TYPE_STRICTLY alarm because 'toFixed' function returns string type.
Compliant Code ExampleView with noncompliant examples side by side
var x = 10 / 3; var b = x.toFixed(1) === "3.3";
This rule was introduced in DeepScan 1.0.0-alpha.