Last active
February 20, 2021 15:09
-
-
Save sayinserdar/7c62556f507ac1c2c405c35447beb6a3 to your computer and use it in GitHub Desktop.
Short circuiting in JS
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
let a; // falsy value | |
let b = predefinedFunctionWhichReturnsFalse(); // false | |
let c = computationallyHeavyFunctionWhichReturnsFalse(); // falsy value | |
let d = false; | |
let e = true; | |
// Needs to evalaute every condition. | |
let result = a | b | c | d | e; | |
// Needs to evaluate only 'e'. | |
let result = e | a | b | c | d; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment