with (document) {
write("x = 11, y = 5");
write("<LI>x + y 是 ", x + y);
write("<LI>x - y 是 ", x - y);
write("<LI>x * y 是 ", x * y);
write("<LI>x / y 是 ", x / y);
write("<LI>x % y 是 ", x % y);
write("<LI>++ x 是 ", ++ x);
write("<LI>-- y 是 ", -- y);
} </Script>
例2: <Script>
var x = y = 3;
with (document) {
write("x = 3, y = 3 <br>");
write("若x = y++ 运算之后:");
x = y++;//y→x,y+1→y
write("x 是 ", x, "; y 是 ", y, "<br>");
write("再作x = ++y 运算:");
x = ++y;//y+1→x,y+1→y
write("x 是 ", x, "; y 是 ", y);
}
</Script>
字符串运算符;
+ +=
比较运算符;
== != ===(值及类型) !==(值及类型)
< <= > >=
例: <Script>
var x = 5; //x 是数值5
var y = '5'; //y 是字符串5
var z = 6; //x 是数值6
with (document) {
write("x = 5, y = '5', z = 6");
write("<LI>x == y 吗?", x == y);
write("<LI>x === y 吗?", x ===
y);
write("<LI>x != y 吗?", x != y);
write("<LI>x !== y 吗?", x !==
y);
write("<LI>x <= z 吗?", x <=
z);
write("<LI>y <= z 吗?", y <=
z);
//类型自动转换
}
</Script>