Except for memory save, there is any functional reason to use undefined
TypeScript?
null
is more convenient in most situations. For example, when using JSON, only null
is accepted.
If I need to return something "undefined" in a function, in TypeScript I could return { a: 123 }
instead of { a: 123, b: undefined }
Can I stop using undefined
? Or there are other reasons to use undefined
instead of null
in TypeScript?
I am talking about an independent strongly typed TS project (without plain Javascript dependencies). I.e. with "strict": true
.
Edit: The question has been marked as duplicated. But the linked question is about Javascript and doesn't respond to my problem. My question is about Typescript only, where the use of undefined is not always required thanks to the Typescript abstractions.