Pull up negation

Move the not-operator (!) out of a binary expression.

Pull up negation

Why is this refactoring helpful?

Pulling a negation out of an expression can be part of a larger refactoring, e.g. when moving the negation to a different location in the code.

What do I need to consider?

When the operator is && or ||, the resulting value can change into a boolean. The falsy/truthy state of the return value will be the same as before, so flipping the operator is often safe in conditions but unsafe in assignments and expressions.

When the operator is <, <=, > or >= the result for NaN and nullish values can change.

Configuration

Related Code Assists

Learn More

Available In