<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title></head><body><p>JavaScript 赋值运算符</p><p id = "a"></p><script>var h = 10;h /= 3;document.getElementById("a").innerHTML = h;</script></body>
</html>
JavaScript 赋值运算符
/= 赋值运算符对变量相除。
赋值
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title></head><body><p>JavaScript 赋值运算符</p><p id = "b"></p><script>var e = 9;e %= 10;document.getElementById("b").innerHTML = e;</script></body>
</html>
JavaScript 赋值运算符
%= 赋值运算符把余数赋值给变量。
赋值
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title></head><body><p>JavaScript 字符串运算符</p><p id = "dd"></p><script>var li1 = "李白";var li2 = "古诗";document.getElementById("dd").innerHTML = li1 + " " + li2;</script></body>
</html>
JavaScript 字符串运算符
+ 运算符也可用于对字符串进行相加(concatenate,级联)
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title></head><body><p>JavaScript 字符串运算符</p><p id = "vv"></p><script>var libai1 = "李白";var libai2 = "古诗";var gushi = libai1 + libai2;document.getElementById("vv").innerHTML = gushi;</script></body>
</html>
JavaScript 字符串运算符
+ 运算符也可用于对字符串进行相加(concatenate,级联)
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title></head><body><p>JavaScript 字符串运算符</p><p id = "kai"></p><script>du = "百度";du += "一下";document.getElementById("kai").innerHTML = du;</script></body>
</html>
JavaScript 字符串运算符
+= 赋值运算符也可用于相加(级联)字符串
在用于字符串时,+ 运算符被称为级联运算符
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title></head><body><p>JavaScript 字符串运算符</p><p id = "ll"></p><script>var h = 3 * 3;var u = "3" + 9;var hh = "百度" + 9;document.getElementById("ll").innerHTML = h + "<br>" + u + "<br>" + hh;</script></body>
</html>
JavaScript 字符串运算符
字符串和数字的相加
相加两个数字,将返回和,但对一个数字和一个字符串相加将返回一个字符串