简单的定义
const numArr:number[]=[1,2,3] const strArr:string[]=['a','b','c'] const undeArr:undefined[]=[undefined,undefined]
数组中有字符串又有数组的类型
const arr:(number|string)[]=[1,'a',2]
数组中对象的定义
const xiaojie:{name:string,age:number}[]=[ {name:"小妹",age:18} ]
或者用别名type
type lady={name:string,age:number} const xiaojiejie:lady[]=[ {name:'韩云',age:18} ]
用class也行
class Madam{
name:string;
age:number;
}
const dajiejie:Madam[]=[]
元祖
const dajiejie:[string,string,number]=['dajiao','teach',29]