Foreword:
you know?. this symbol
For example, some objects have children as an array, and some objects have children as null. For example, some objects have children as an array, and some objects have children as null.
Null coalescing symbol ??
Only when the left side is null and undefined, the number on the right side will be returned
const too = null ?? 'default string'
// default string
?. optional operator
Does not raise an error if the reference is null or undefined,
const adventurer = {
name :'abc',
cat:{
name:'maomi'
}
}
const dogName = adventurer.dog?.name
console.log(dogName) // unidefine
My brain is full of knowledge~