Using function's return value in if statement

前端 未结 5 984
你的背包
你的背包 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 05:56

    You can simply use

    if(queryThis('foo')) { doThat(); }
    
    function queryThis(parameter) {
        // some code
        return true;
    }
    

提交回复
热议问题