原始类型和对象类型
原始类型的类型标注
ts
const name: string = "title";
const age: number = 24;
const male: boolean = false;
const undef: undefined = undefined;
const nul: null = null;
const obj: object = { name, age, male };
const bigintVar1: bigint = 9007199254740991n;
const bigintVar2: bigint = BigInt(9007199254740991);
const symbolVar: symbol = Symbol("unique");
null 与 undefined
- null 与 undefined 分别表示“这里有值,但是个空值”和“这里没有值”
void
- void 操作符强制将后面的函数声明转化为了表达式