在if语句中使用函数的返回值 [英] Using function's return value in if statement
本文介绍了在if语句中使用函数的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
希望这里有个简单的问题.
Hopefully a quick question here.
可以在if语句中使用函数的返回值吗?即
Can you use a function's returned value in a if statement? I.e.
function queryThis(request) {
return false;
}
if(queryThis('foo') != false) { doThat(); }
我敢肯定,这很简单明显,但是我遇到了一些语法错误问题,我无法确定问题所在.
Very simple and obvious I'm sure, but I'm running into a number of problems with syntax errors and I can't identify the problem.
推荐答案
您可以简单地使用
if(queryThis('foo')) { doThat(); }
function queryThis(parameter) {
// some code
return true;
}
这篇关于在if语句中使用函数的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文