上QQ阅读APP看书,第一时间看更新
Types: undefined and null
In TypeScript, undefined and null are types themselves; this means that undefined is a type (undefined) and null is a type (null). Confusing? undefined and null cannot be type variables; they can only be assigned as values to variables.
They are also different: a null variable means that a variable was set to null, while an undefined variable has no value assigned.
let A = null;
console.log(A) // null
console.log(B) // undefined