<html>
<head>
<title>一个用break中断循环的Javascript代码示例</title>
<script type="text/javascript">
function BreakTest(breakpoint){
var i = 0;
var m = 0;
while (i < 100)
{
//当 i 等于breakpoint时,中断循环
if (i == breakpoint)
break;
m=m + i;
i++;
}
return(m);
}
</script>
</head>
<body>
<script type="text/javascript">
//设函数BreakTest参数breakpoint值为23,得到从1加到22的合计。
document.write(BreakTest(23))
</script>
</body>
</html>