1 var a=1; 2 var b=2; 3 4 var c=a+b;//3 5 var s=1+"fly";//"1fly"
以上是加号作为二元运算符时的使用方法。
当加号作为一元运算符呢?
1 var s="1"; 2 var s1="2"; 3 var s2=+s;//s2=1
加号相当于一个爆米花机了,而紧随其后的非数字字符串就是即将要被处理的爆米花。
是+s=Number(s)。
是Number()函数的简写。