JS 运算符
运算符 = 用于赋值。
运算符 + 用于加值。
JavaScript 算术运算符
+ - * / % ++ --
JavaScript 赋值运算符
= += -= *= /= %=
用于字符串的 + 运算符
txt1="What a very";
txt2="nice day";
txt3=txt1+txt2;
//"What a verynice day"
txt1="What a very ";
txt2="nice day";
txt3=txt1+txt2;
//"What a very nice day"
txt1="What a very";
txt2="nice day";
txt3=txt1+" "+txt2;
//"What a very nice day"
对字符串和数字进行加法运算
x=5+5;
document.write(x);
x="5"+"5";
document.write(x);
x=5+"5";
document.write(x);
x="5"+5;
document.write(x);
10/55/55/55
规则是:
如果把数字与字符串相加,结果将成为字符串。