Skip to content

Instantly share code, notes, and snippets.

@kavitshah8
Last active December 13, 2015 03:28
Show Gist options
  • Save kavitshah8/e2b1da3b2e1d46a697ae to your computer and use it in GitHub Desktop.
Save kavitshah8/e2b1da3b2e1d46a697ae to your computer and use it in GitHub Desktop.
Logical operators
'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