It's a hacky way, with a dynamically-typed language, to write terser code with potential null values. It doesn't really solve the problem of programmers forgetting to check for nullity, since there's nothing stopping a programmer from forgetting to use ? there.
Yep. This is why I always enable "strictNullChecks" (or "strict" in general) on every typescript project. You get an "object may be undefined" error and it doesn't compile.
there is though. Typescript and your IDE will show an error that the value you are trying to access may be undefined, forcing you to either use optional chaining or another form of null check
1
u/FunkyFreshFarming Nov 10 '20
Can someone help ELI5 for a jr developer?