由于错过了直播,只好自己看文档总结了。
-
布尔类型(boolean)
const type: boolean = true; -
Number 类型
const type: number = 1; -
String 类型
const type: string = "string"; -
Enum 类型
enum People{ white, yellow, black, } const person: Color = Peole.white; console.log(white); // 0 -
数组类型(array)
const arry1: number[] = [1, 2, 3]; const arry2: Array<number> = [1, 2, 3]; -
元组类型(tuple)
const type: [string, number] = ["string", 1]; -
Symbol
const sym1 = Symbol("string"); const sym2 = Symbol("string"); console.log(Symbol("string") === Symbol("string")); -
any
const type: any -
null 和 undefined
let type1: undefined = undefined; let type2: null = null;