0

I came across the scenario trying with different operating concatenations. I am wondering how this condition was working for the 2nd statement.

  1. console.log("10"+9); // 109

  2. Console.log("10"-9); //1

Can Someone tell me what's happening here?

0

2 Answers 2

4

+ 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.

Sign up to request clarification or add additional context in comments.

Comments

0

The plus sign is both an Arithmetic operator and the String Concatenation operator. The concatenation has precedence.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.