網頁特效 ++ 與--操作符的使用方法
先來看看關於 --
<html>
<script language="JavaScript">
<!--
document.write("<h3>Before Pre-decrement</h3>");
num = new String("8");
document.write("num=",num,"<br>");
returnValue = --num;
document.write("<h3>After Pre-decrement</h3>");
document.write("num=",num,"<br>");
document.write("Value returned from operation is ",returnValue,"<br>");
returnValue = num--;
document.write("<h3>After Post-decrement</h3>");
document.write("num=",num,"<br>");
document.write("Value returned from operation is ",returnValue,"<br>");
-->
</script>
</html>
i++執行個體
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
var a = 6, b = 2;
alert(++a + b);
// -->
</script>
</head>
<body>
</body>
</html>
-- i執行個體
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
var a = 6, b = 2;
alert(--a + b);
// -->
</script>
</head>
<body>
</body>
</html>