3 ms·
I've never found a use for null where undefined wouldn't be simpler to use. Especially with the ?? Operator to set defaults along the way
by 8note 4y ago
I've never found a use for null where undefined wouldn't be simpler to use. Especially with the ?? Operator to set defaults along the way
- j1elo 4y agoThis is a very curious and fun way to put it: https://stackoverflow.com/a/57249968 https://stackoverflow.com/a/57249968 In essence, `undefined` is non-existence. And `null` is existence with a non- (or "invalid", or "unknown") value. Although using them like that depends on the needs of the application. If "invalid" or "unknown" was an expected user choice, I would still rather encode it as an enum better than a nullable boolean, as mentioned in my comment above.