Use == null comparison
Replace different nullish checks with
== null check is a concise expression to identify nullish values (
This refactoring replaces the following combinations of longer strict equality checks with the shorter
a === null || a === undefinedbecomes
a == null
b !== null && b !== undefinedbecomes
b != null
x.f(1, 2) === null || x.f(1, 2) === undefinedbecomes
x.f(1, 2) == null
What do I need to consider?
When two similar-looking function calls have a side effect, this refactoring can change the behavior of the code.
For example, the refactoring changes:
let a = f(1) === null || f(1) === undefined;
let a = f(1) == null;
f(1) has a side effect, it would have been called once or twice before the refactoring, and once after the refactoring.
This means that the side effect would have been called a different number of times, potentially changing the behavior.
- Code Assist ID (for the configuration file):
- You can configure custom keyboard shortcuts with these code action kinds:
- This code assist provides refactoring suggestions. Learn how to configure the refactoring suggestion visibility.