Created
May 21, 2019 13:17
-
-
Save vaidd4/279bfa7b378b3dbfd0489df58bd86999 to your computer and use it in GitHub Desktop.
JS handling of undefined & null as object properties
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 obj = { a: 'a', b: null, undefined: 'undef', null: 'nil' } | |
obj['a'] // 'a' | |
obj[obj.b] // 'nil' | |
obj[obj.c] // 'undef' (obj.c is undefined) | |
obj[obj] // undefined | |
// Can be used for making conditions with objects |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment