DEV Community

Discussion on: 😰 Optional chaining trap !

Collapse
 
thekashey profile image
Anton Korzunov

What are you doing so deep in an object structure?

Exactly the point! If a top level key is not accessible, then:

  • why it's not accessible? it is null, undefined, so you can't go deeper, or it string, and your data type is too mutable? It's a quite popular to have something which could be "string/object" or "object/function". Why?
  • then may be another keys from the same location, you are going to read a moment later is also not accessible. Why? May be some decision should be made a bit before? Why?
  • and of course - why some data (you got from the network) might unpredictable not exists, and you are not "ready" for this. Why?