Last active
July 18, 2018 09:21
-
-
Save tarasowski/84dea4cd1d216ef5be55e176e66c8aa8 to your computer and use it in GitHub Desktop.
#JavaScript - Short Circuit
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 isVarAssigned = false | |
// if isVarAssigned is true, assign the value else assign 'There is no variable assigned' String | |
const x = isVarAssigned || 'There is no variable assigned' | |
console.log(x) | |
// if isVarAssigned is true go and assign the value 'Yes the variable is assigned' if false assign false | |
const y = isVarAssigned && 'Yes there is a variable assiged' | |
console.log(y) | |
// There is no variable assigned | |
// false | |
// good description why and how: http://www.openjs.com/articles/syntax/short_circuit_operators.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment