Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

optional chain operator

const adventurer = {
  name: 'Alice',
  cat: {
    name: 'Dinah'
  }
};

const dogName = adventurer.dog?.name;
console.log(dogName);
// expected output: undefined
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #optional #chain #operator
ADD COMMENT
Topic
Name
2+7 =