Last active
December 13, 2015 03:28
-
-
Save kavitshah8/e2b1da3b2e1d46a697ae to your computer and use it in GitHub Desktop.
Logical operators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
function f1 () { | |
console.log('f1 called'); | |
return false; | |
} | |
function f2 () { | |
console.log('f2 called'); | |
return true; | |
} | |
// Short Circuit operator && - That is, f2() is not evaluated if f1() is false, both functions must return boolean | |
var f3 = f1() && f2(); // f1 called | |
// Short Circuit operator && - That is, f2() is not evaluated if f1() is true, both functions must return boolean | |
var f4 = f1() || f2(); // f1 called \n f2 called | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment