Push operator into assignment

Move an operator from a binary expression into an assignment operator, e.g., +=.

Refactoring
ES2021
P42 for VS Code
P42 for GitHub
Push operator into assignment

Why is this refactoring helpful?

Moving an operator into the assignment is a more concise notation that emphasizes that a variable is modified with an update relative to its current value.

What do I need to consider?

Logical Assignment Operators (&&=, ||= and ??=) are an ES2021 feature. They are supported on all modern browsers and on Node 15+, and but for older browsers and Node versions transpilation might be required (compatibility).

Related Code Actions

Learn More

Available In