Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I came across the scenario trying with different operating concatenations. I am wondering how this condition was working for the 2nd statement.
console.log("10"+9); // 109
Console.log("10"-9); //1
Can Someone tell me what's happening here?
+ is used for both string concatenation and addition. If either operand is a string, concatenation is used. - is only used for subtraction, both operants are always coerced to numbers.
+
-
Add a comment
The plus sign is both an Arithmetic operator and the String Concatenation operator. The concatenation has precedence.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.