Javascript 实现 goto

<script type="text/javascript">
test1 : for (var i = 0; i < 3; i++) {
test2 : for (var j = 0; j < 3; j++) {
if (i == 1 && j == 1) {
continue test1;
} else {
alert("i = " + i + ", j = " + j);
}
}
}
/*Output is:
"i = 0, j = 0"
"i = 0, j = 1"
"i = 0, j = 2"
"i = 1, j = 0"
"i = 2, j = 0"
"i = 2, j = 1"
"i = 2, j = 2"
Notice how it skips both "i = 1, j = 1" and "i = 1, j = 2"
*/
</script>
posted @ 2012-02-22 17:32  microsoft_kk  阅读(1131)  评论(0编辑  收藏  举报