Adding and subtracting strings and numbers in Javascript - auto type conversion?

前端 未结 5 1808
抹茶落季
抹茶落季 2020-12-04 01:52

Let\'s look at the following Javascript code.



        
5条回答
  •  情歌与酒
    2020-12-04 02:47

    + is used for both string concatenation and addition. If either operant is a string, concatenation is used. - is only used for subtraction, both operants are always cast to numbers.

提交回复
热议问题