<head>
<meta charset="UTF-8">
<title>5运算符</title>
</head>
<body>
<script>
//1:赋值运算符 "="
//2:算术运算符 +,-,*,/,%,++,--
var str = "10";
document.writeln("str+3:"+(str+3)+"<br>");
document.writeln("str-3:"+(str-3)+"<br>");
document.writeln("str*3:"+(str*3)+"<br>");
document.writeln("str/3:"+(str/3)+"<br>");
document.writeln("str%3:"+(str%3)+"<br>");
document.writeln("str++:"+(++str)+"<br>");
document.writeln("str--:"+(--str)+"<br>");
document.writeln("<hr>");
//3:符合运算符 +=,-=,/=,*=,%=
//4:关系运算符 >,<,>=,<=,!=,==,===,!==
var n1 = "100"
, n2 = 100;
document.writeln(n1+"="+n2+"?"+(n1==n2));//==只比内容,不比类型
document.writeln(n1+"="+n2+"?"+(n1===n2));//===比内容,也比类型
document.writeln("<hr>");
//5:逻辑运算符 &,|,!,^,&&,||,,,js中两边可以放任何数据类型
var n3 = "apple"
, n4;
document.writeln("<br>");
document.writeln("n3:"+n3+"<br>");
document.writeln("n4:"+n4+"<hr>");
n3 = n3||"无名氏"
n4 = n4||"无名氏" //n4为负值:强转之后为false,所以n4="无名氏"
document.writeln("n3:"+n3+"<br>");
document.writeln("n4:"+n4+"<hr>");
//6:三目运算符 表达式?值1:值2
</script>
</body>