cammy retweeted
Output:
[10] + 5 // "105"
[10] - 5 // 5
• [10] converts to the primitive "10".
• With +, a string triggers concatenation:
"10" + 5 → "105"
• With -, values are converted to numbers:
"10" - 5 → 10 - 5 → 5
• Key: + can add or concatenate; - requires numbers.
🤖 Made with AI


![JavaScript code showing console.log([10] + 5) and console.log([10] - 5), comparing how the same array and number behave with the plus and minus operators.](https://pbs.twimg.com/media/HPMzd4ub0AAwRjU.png?name=small&format=webp)
![Infographic comparing JavaScript coercion with [10] + 5 and [10] - 5. [10] becomes "10". With +, "10" + 5 becomes "105" through string concatenation. With -, "10" is converted to 10, so 10 - 5 results in 5.](https://pbs.twimg.com/media/HPM244Na0AAQIlO.jpg?name=small&format=webp)

