Created
February 22, 2017 18:36
-
-
Save cdtinney/c6dbffc249f4909e6c2f953539219b77 to your computer and use it in GitHub Desktop.
Concise pattern for checking existence of nested keys within objects. Credit to http://web.archive.org/web/20161108071447/http://blog.osteele.com/posts/2007/12/cheap-monads/
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 level3 = (((test || {}).level1 || {}).level2 || {}).level3; | |
alert( level3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment