数据类型包括:
1.number
2.boolean
3.string
4.literal类型
5.类型的并集
6.any类型
7.undefined类型例如:
function f(s:200 | 400 | 500 | '200' | '400' | '500'){
//union of types string | number
let status : string | number = s
}undefined 类型的值只有一种就是:undefined
例如:
let answer : 'yes' | 'no' | 'maybe'|undefined = undefinedlet a : any = 'abc' //为了类型兼容,不受编译器的控制,但是并不意味着运行不报错
a = 123
a = {}
a.name='John' | 留言与评论(共有 0 条评论) “” |