Created
March 3, 2012 20:48
-
-
Save Pindar/1968137 to your computer and use it in GitHub Desktop.
JavaScript use of && to prevent errors caused by undefined variables.
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
var foo = { | |
t: { | |
s: function () { | |
console.log("bar"); | |
} | |
} | |
}, | |
bar = foo && foo.t && foo.t.s; | |
if (bar) { | |
bar(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment