Question

I would like to implement short circuit evaluation logic in my code. And I want to know about the full details how it works?

Ex:

function a() {return true;}

function b() {return false;}

function c() {return true;}

Expression

Case 1) a() && b() && c();

Case 2) a() || b() && c();

Case 3) a() && c() || b();

Case 1:

b() will not be executed.

Case 2:

b() and c() will not be executed

Case 3:

c() will not be executed.

Where should we learn about this short-circuit evaluation?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top