I have this array of object
const a = {a:[{b:[{prop: 10}]}]}
to access the value of 10 I do
a.a[0].b[0].prop // 10
I use this fallback, make sure things doesn't break but it didn't work?
a?.a[0]?.b[0]?.prop
, I can use something like lodash's get or check using the old method but how to use the question mark syntax?
Optional chaining should be written as below
a?.[0]?.b?.[0].prop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With