https://github.com/srect/typescript
typescript练习
https://github.com/srect/typescript
typescript
Last synced: 5 months ago
JSON representation
typescript练习
- Host: GitHub
- URL: https://github.com/srect/typescript
- Owner: sRect
- Created: 2018-10-24T15:08:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-17T05:42:10.000Z (almost 2 years ago)
- Last Synced: 2025-05-15T17:50:54.421Z (about 1 year ago)
- Topics: typescript
- Language: TypeScript
- Size: 43.9 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## TypeScript
1. 变量的类型
```javascript
/**
* 数据类型
* Undefined :
* Number:数值类型(NaN,Infinity,-Infinity);
* string : 字符串类型;
* Boolean: 布尔类型;
* enum:枚举类型;
* any : 任意类型,一个牛X的类型;
* void:空类型;
* Array : 数组类型;
* Tuple : 元祖类型;
* Null :空类型
*/
var str: string = "hello world";
console.log(str)
var num: number = NaN;
var num2: number = 18;
var num3: number = 175.5;
console.log(num, num2, num3);
enum MOBILE { xiaomi, huawei, vivo, oppo };
enum REN { nan = "男", nv = "女", yao = "妖" }
console.log(MOBILE.huawei)
console.log(REN.nv)
var a: any = true;
a = 18;
a = "hello";
console.log(a)
```