ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Code Inspection: Using of coerced equality

Last modified: 21 July 2022

In JavaScript and TypeScript code, ReSharper suggests replacing the equality operator == with a stricter identity operator ===. Using === is a good practice because == may work unpredictably — the reason is that the == operator performs type coercing (conversion) before comparison, which may lead to unexpected results of comparison. The identity operator ===, which works only with operands of identical type, prevents such errors. You can learn more about these operators in the answers to this StackOverflow question.

In the example, ReSharper recommends using the identity operator: