Last active
May 11, 2021 19:59
-
-
Save pjcodesjs/4d5185a9266fa76b201791f54c002ce2 to your computer and use it in GitHub Desktop.
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
// OPTIONAL CHAINING EXAMPLE | |
let character = { | |
name: 'Dean Winchester', | |
age: 34, | |
car: 'Chevy Imala (Baby)', | |
enemy_demons: [ 'Abadon', 'Yellow Eyes', 'Crowley' ], | |
enemy_angels: [ 'Zacharia', 'Michael', 'Lucifer' ], | |
family: { | |
mother: 'Mary', | |
father: 'John', | |
brother: 'Sam', | |
} | |
} | |
const friend = character.friend?.name; | |
console.log(friend) // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment