Created
June 26, 2013 14:11
-
-
Save ultim8k/5867669 to your computer and use it in GitHub Desktop.
Short-circuit evaluation (AKA lazy assignment)
This file contains hidden or 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
/** | |
* Short-circuit evaluation AKA lazy assignment | |
*/ | |
var a; | |
var b = null; | |
var c = undefined; | |
var d = 4; | |
var e = 'five'; | |
var f = a || b || c || d || e; | |
console.log(f); // 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment