break和continue的实现
2007-11-26 12:02
197 查看
<script type="text/javascript">
var $break = {}, $continue = {};
/*
转:prototype.js
*/
var check = function () {
var a = Array.apply(null, arguments), f = a.shift(), o = a.shift();
try {
f.apply(o, a);
} catch (exp) {
if (exp !== $break) throw exp;
}
};
var each = function (f) {
var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], i = 0;
for (; i < a.length ; i ++) {
try {
f(a[i]);
} catch (exp) {
if (exp !== $continue) throw exp;
}
}
};
check(each, null, function (a) {
if (a < 8) {
if (a == 4) throw $continue;
else document.write(a);
} else throw $break;
});
</script>
var $break = {}, $continue = {};
/*
转:prototype.js
*/
var check = function () {
var a = Array.apply(null, arguments), f = a.shift(), o = a.shift();
try {
f.apply(o, a);
} catch (exp) {
if (exp !== $break) throw exp;
}
};
var each = function (f) {
var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], i = 0;
for (; i < a.length ; i ++) {
try {
f(a[i]);
} catch (exp) {
if (exp !== $continue) throw exp;
}
}
};
check(each, null, function (a) {
if (a < 8) {
if (a == 4) throw $continue;
else document.write(a);
} else throw $break;
});
</script>
相关文章推荐
- jquery each循环,要实现break和continue的功能
- scala中break与continue的实现
- Break,continue,return来实现控制语句的跳转和中断
- jquery each 函数里面如何实现break与continue?
- oracle中实现continue,break
- JAVA中Goto和continue、break实现Goto
- C++ 退出双层for循环,解决 break、return、continue无法实现问题
- break、continue关键字配合标签使用,实现跳转功能
- scala中实现break与continue功能
- Java通过continue、break与标签实现Goto
- oracle中实现break和continue
- jquery each循环,实现break和continue的功能
- break、continue关键字配合标签使用,实现跳转功能
- java中break,continue,标签实现goto效果(编程思想)
- 用while(true)和continue、break来实现在一个大循环里switch
- 用while(true)和continue、break来实现在一个大循环里switch
- jQuery的each方法中实现continue和break的流控制
- oracle中实现continue,break .
- 循环标签的使用,for,break, continue,label
- 循环结构中break、continue、return和exi()t的区别