One or both of the variables is a string instead of a number. This makes the +
do string concatenation.
'2' + 2 === '22'; // true
2 + 2 === 4; // true
The other arithmetic operators / * -
will perform a toNumber
conversion on the string(s).
'3' * '5' === 15; // true
A quick way to convert a string to a number is to use the unary +
operator.
+'2' + 2 === 4; // true
...or with your variables:
+x + +y
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…