Typography - What is the difference between null and undefined?

advertisements

This question already has an answer here:

  • What is the difference between null and undefined in JavaScript? 29 answers

I want to know what is the difference between null and undefined in typescript. I know in javascript it is possible to use both of them in order to check a variable has no value. But in typescript I want to know the difference exactly and when it is better to use each one of them. Thanks.


This post explains the differences very good. They are the same in Typescript as in Javascript.

As for what you should use: The Typescript coding styleguide itselft states that you should always use undefined and not null: Typescript Styleguide