You are retrieving some data from API. Till you retrieve the data, you should have something like data: null, after you get data from API, you should have the whole object.
API should always return you a predefined object structure, right? So once data !== null, you should be able to access all properties and deep properties instead of checking every object in your structure.
I understand that there might be some valid cases where object?.property?.property might be a shorter code, but it doesn't mean it should be implemented in the language.
Once this is in language, the syntax will be overused and more shitty code will be written.
Assuming that objects returned from third-parties conform to a specific structure (and therefore, not 'verifying' their structure and the presence/lack-thereof of expected properties) is most-likely a security blunder.
You are retrieving some data from API. Till you retrieve the data, you should have something like
data: null
, after you get data from API, you should have the whole object.API should always return you a predefined object structure, right? So once
data !== null
, you should be able to access all properties and deep properties instead of checking every object in your structure.I understand that there might be some valid cases where
object?.property?.property
might be a shorter code, but it doesn't mean it should be implemented in the language.Once this is in language, the syntax will be overused and more shitty code will be written.
What if the API is not in your hand and you have no control over it?
I don't see it being overused in ruby or c# or any other language. Why should this happen in JS?
Assuming that objects returned from third-parties conform to a specific structure (and therefore, not 'verifying' their structure and the presence/lack-thereof of expected properties) is most-likely a security blunder.
Sorry, I don't fully understand what you mean.