1/0 java中会抛出java.lang.ArithmeticException: / by zero
而js并不会报错,会输出Infinity:无穷
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>进击的巨人--JS</title>
<script>
document.write("<h1>算术运算符的用法:</h1>");
document.write("3+6="+(3+6)+" <br>");
document.write("3-6="+(3-6)+" <br>");
document.write("3*6="+(3*6)+" <br>");
document.write("1/0="+(1/0)+" <br>"); //Infinity:无穷
document.write("55%3="+(55%3)+" <br>");
var a=b=c=d=3;
document.write(a+"++结果是:"+(a++)+"<br/>");
document.write("++"+b+"结果是:"+(++b)+"<br/>");
document.write(c+"--结果是:"+(c--)+"<br/>");
document.write("--"+d+"结果是:"+(--d)+"<br/>");
</script>
</head>
<body>
</body>
</html>
|