3 ms·
The lodash functions have built in guards so you can do _.map() and not have to care if the argument you pass in is, in fact, an Array. I can’t tell you how ma
by Osiris 4y ago
The lodash functions have built in guards so you can do _.map() and not have to care if the argument you pass in is, in fact, an Array.
I can’t tell you how many times I see “can’t call function toLowerCase of undefined”, etc.
“but Typescript!”, doesn’t do runtime type checking.
I very much prefer defensive programming. Assume nothing.
- factormeta 4y ago>I can’t tell you how many times I see “can’t call function toLowerCase of undefined”, etc. Think that should be addressed by optional chaining now.
- Osiris 4y agoPartly but optional chaining doesn't make sure that the function actually exists on the target. So if "const a = 10" and you call "a?.toLowerCase()" you'll still get an error.