Optional Chaining (?.) - JavaScript MDN
Optional chaining (?.) - JavaScript | MDN
Example 1
const adventurer = {
name: 'Alice',
cat: {
name: 'Dinah'
}
};
const dogName = adventurer.dog?.name;
console.log(dogName);
// expected output: undefined
console.log(adventurer.someNonExistentMethod?.());
// expected output: undefined
Example 2
This returns: Cannot read includes property of undefined if array has item without frontmatter[keyChoice]
queryFiles = files.filter(file => app.metadataCache.getFileCache(file).frontmatter[keyChoice].includes(queryValue));
This
queryFiles = files.filter(file => app.metadataCache.getFileCache(file).frontmatter[keyChoice]?.includes(queryValue));