15.7 Common Pitfalls: Assignment vs Equality in Conditions
A pervasive and often subtle error in many programming languages involves mistakenly using the assignment operator (=) when the equality operator (== or ===) is intended within the conditional expression of control flow statements like if, while, or for. This mistake can lead to logic bugs that are notoriously difficult to track down because the code is syntactically correct—it will run without throwing an immediate error—but will behave in unexpected and incorrect ways.