Using function's return value in if statement

前端 未结 5 964
你的背包
你的背包 2021-02-09 05:54

Hopefully a quick question here.

Can you use a function\'s returned value in a if statement? I.e.

function queryThis(request) {

  return false;

}

if(q         


        
5条回答
  •  失恋的感觉
    2021-02-09 06:22

    In sort, yes you can. If you know it is going to return a boolean you can even make it a bit simpler:

    if ( isBar("foo") ) {
      doSomething();
    }
    

提交回复
热议问题