vendredi 1 janvier 2016

Detecting result of a logical OR in JS conditional

Is there a good way to detect which half of a logical or within a conditional is true?

// foo would return true or false    
if (thing1 === "3" || thing2 === foo()) {

     // do something if thing1 is 3
     // do something different if thing2 is true


};

Or should I just use two nested if blocks?

Aucun commentaire:

Enregistrer un commentaire