So, I am reading optional chaining in JavaScript and a question popped into my head.
Consider the code below:
let person = null
let street = person?.street // returns undefined
My question is that, if the variable person is null to begin with, then why is doing optional chaining result to setting the variable as undefined and not null?
If the person was undefined, then I guess, for me, setting it to undefined is reasonable because the variable is of course undefined, like the below:
let person
let street = person?.street // returns undefined
PS: I'm sorry if this is a stupid question, I'll delete it if someone agrees. :)
PPS: If this question is duplicated, pls drop the link and I'll give it a go. Thank you, very much.