At first glance, this looks confusing: "5" - -"2" → 7 But it’s actually a clean example of how type coercion works in JavaScript. Here’s the breakdown: "2" → 2 -"2" → -2 (unary minus forces number conversion) "5" → 5 So: 5 - (-2) = 7 One important detail: There is no + operator involved, so string concatenation never comes into play. Concepts like this are frequently used in interviews to test clarity around type coercion. Once you understand the rules, these questions stop being tricky. 👉 I’ve explained this and similar concepts step-by-step in the full video (link in comments)

To view or add a comment, sign in

Explore content categories