Skip to main content

Suspicious use of the Equal To operator

In This Article

Note

The Suspicious use of the Equal To operator code issue is JavaScript specific.

CodeRush Classic shows the Suspicious use of the Equal To operator code issue if the “==” operator is used to compare values.

#Fix

Replace the “==” operator with “===”.

#Purpose

Highlights usages of the “==” operator, which can be replaced with the “===” operator for strict comparison.

#Example

if (obj1 == obj2)
    document.createTextNode("Objects are equal"));

Fix:

if (obj1 === obj2)
    document.createTextNode("Objects are equal"));