Two Ampersands Between Function Calls

前端 未结 4 1442
暖寄归人
暖寄归人 2020-12-21 04:04

What do two ampersands separating function calls do? Note: this is OUTSIDE any if statement or case statement

Like so:

functionCallOne() && f         


        
4条回答
  •  攒了一身酷
    2020-12-21 04:34

    it is equivalent to

    if ( functionCallOne() ) {
      functionCallTwo();
    }
    

    it just uses the short circuiting to make this 3 liner only take up one line

提交回复
热议问题