Difference between Null and UndefinedNullNull is used to represent an intentional absence of value. It represents a variable whose value is undefined. It accepts only one value, which is null. The Null keyword is used to define the Null type in TypeScript, but it is not useful because we can only assign a null value to it. ExampleOutput: UndefinedIt represents uninitialized variables in TypeScript and JavaScript. It has only one value, which is undefined. The undefined keyword defines the undefined type in TypeScript, but it is not useful because we can only assign an undefined value to it. ExampleOutput: Null vs. UndefinedThe important difference between Null and Undefined are:
Next TopicTypeScript Variables |