We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript支持与JavaScript几乎相同的数据类型,此外还提供了实用的枚举类型方便我们使用
let isDone: boolean = false;
let decLiteral: number = 6; let hexLiteral: number = 0xf00d; let binaryLiteral: number = 0b1010; let octalLiteral: number = 0o744;
let name: string = "bob";
TypeScript中两种方式可以定义数组: 第一种,可以在元素类型后面接上[],表示由此类型元素组成的一个数组:
let list: number[] = [1, 2, 3];
第二种是使用数组泛型,Array<元素类型>,关于泛型后面会介绍
let list: Array<number> = [1, 2, 3];
let x: [string, number]; x = ['hello', 12];
enum Color { Red = 1, Green, Blue } let a: string = Color[2]; console.log(a); //Green
The text was updated successfully, but these errors were encountered:
No branches or pull requests
简介
TypeScript支持与JavaScript几乎相同的数据类型,此外还提供了实用的枚举类型方便我们使用
常见基本数据类型
TypeScript中两种方式可以定义数组: 第一种,可以在元素类型后面接上[],表示由此类型元素组成的一个数组:
第二种是使用数组泛型,Array<元素类型>,关于泛型后面会介绍
元组类型允许表示一个已知元素数量和类型的数组,各元素的类型不必相同。
enum类型是对JavaScript标准数据类型的一个补充。
在TypeScript里,undefined和null两者各自有自己的类型分别叫做undefined和null,维持了和JavaScript一致的
The text was updated successfully, but these errors were encountered: