基本类型
- number
- string
- boolean
- Array
- undefined
- void
- 元组
- any
/**
* 基本类型
*/
//number
let age:number=12
console.log('age=',age)
//string
let city:string='Beijing'
console.log('city=',city)
//boolean
let isChina:boolean=true
console.log('isChina=',isChina)
//Array
let arr1:number[]=[1,3,5,7]
console.log('arr1=',arr1)
let arr2:Array<number>=[2,4,6,8]
console.log('arr2=',arr2)
//undefined
let x=undefined
console.log('x=',x)
let y
console.log('y=',y)
//元组-表示已知元素数量和类型的数组
let a:[string,number]
a=['张三',12]
console.log('a=',a)
//any-任意类型
let b:any=1;
console.log('b=',b)
b='xyz'
console.log('b=',b)
网友评论