I'm trying to use optional chaining with an array instead of an object but not sure how to do that:
Here's what I'm trying to do myArray.filter(x => x.testKey === myTestKey)?[0]
.
Also trying similar thing with a function:
let x = {a: () => {}, b: null}
console.log(x?b());
But it's giving an error like that so how to use it with an array or a function.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…