标签:易搞混淆的点
1.输出1-100之间的所有数:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>作业1</title>
<script type="text/javascript">
//定义变量
var i = 1;
while( i<=100 )
{
document.write(i+" ");
i++;
}
</script>
</head>
<body>
</body>
</html>2.输出1-100之间的数:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>作业1</title>
<script type="text/javascript">
//定义变量
var i = 0;
while( i<100 )
{
i++;
document.write(i+" ");
}
</script>
</head>
<body>
</body>
</html>两种写法输出的结果一致,但是其中的条件却是不一样的。当“i++”与“document.write(i+" ");”是i++在前,document.write(i+" ");在后,则条件如2;如果是document.write(i+" ");在前,i++在后,则条件如1.
i++与document.write(i+" ");的位置不同,结果也不同。
本文出自 “UI大师” 博客,请务必保留此出处http://475281641.blog.51cto.com/11320682/1775563
标签:易搞混淆的点
原文地址:http://475281641.blog.51cto.com/11320682/1775563