I was taking this JavaScript Quiz and found this question -
"1" - - "1";
The result of this statement is 2.
Can anyone explain what is going on here?
I also found that with even - the addition of strings take place but with odd - subtraction. This only happens when a number is a string.
Here are some more eamples-
"1" - "1" => 0
"1" - - "1" => 2
"1" - - - "1" => 0
"1" - - - - "1" => 2
"a" - "b" => NaN
-on a string will coerce the string to a Number+"1" + +"1"=>2, but"1" + "1"=>"11".