如何调用外部函数从内部函数返回? [英] How to call outer function's return from inner function?
本文介绍了如何调用外部函数从内部函数返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的代码:
function allValid() {
$('input').each(function(index) {
if(something) {
return false;
}
});
return true;
}
总是返回true,因为返回false;
影响匿名内部函数。是否有一种简单的方法可以调用外部函数的返回值?
which always returns true as return false;
affects anonymous inner function. Is there an easy way to call outer function's return?
PS。我不是在寻找解决方法,只是想知道答案原始问题。如果答案不可能,那就没关系。
PS. I am not looking for a workaround, just want to know the answer to original question. If the answer is "not possible" it is fine.
推荐答案
是的,将它存储在局部变量中。
Yeah, store it in a local variable.
function allValid() {
var allGood = true;
$('input').each(function (index) {
if (something) {
allGood = false;
}
});
return allGood;
}
这篇关于如何调用外部函数从内部函数返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文