-converts both operands to numbers. But if either operand in +is a string, the other is converted to a string and represents concatenation. Like "Hi, " + "how are you?" = "Hi, how are you?"So, your answers are correct.
var x = 1+"2"-3;
// concats the string as 12 and then subtracts...
12 - 3 = 9
var y = 1-"2"+4
// converts to numbers and subtracts, making -1 and then adds 4 giving out 3
-1 + 4 = 3
It was a process.
source
share