3 ms·
See, I take the opposite view: consider that the 'model' is the abstract structure of the data which your application knows about. In your case, contact info i
by nateabele 7y ago
See, I take the opposite view: consider that the 'model' is the abstract structure of the data which your application knows about.
In your case, contact info is a piece of related data that your application knows about, can traverse to, parse, and consume, and it can be either present or absent. To me, `null` fits that case perfectly (personally I'd use Maybe, but, same idea). Finally, in cases where you're modeling a collection of values where the keys are unknown, see `dict()`.
- Gehinnn 7y agoWhat is `dict()`? What's the meaning of `null`? `undefined` literally means the value is not defined. `null` only has a technical meaning, which says its value is the null pointer.
- Dylan16807 7y agoThat's not what null means in javascript and typescript. There, it's more like 'null' signals that there is no value, and 'undefined' signals that there is no variable.
- Gehinnn 7y agoAll runtime differences are quite neglectable if you use typescript, at least in my experience. You never accidentally use unassigned variables in typescript. Also, `{ x: undefined }` and `{}` are distinguishable. Undefined plays well together with optional fields in typescript, null does not and requries normalization! `undefined` in a JSON array is a problem though.