元组
元组类型用来表示已知元素数量和类型的数组,各元素的类型不必相同,对应位置的类型需要相同。
let x: [a:string, b:number];
x = ['abc', 100] //okay
x = [12, 'hello']; //error
console.log(x[0]); //abc
元组类型用来表示已知元素数量和类型的数组,各元素的类型不必相同,对应位置的类型需要相同。
let x: [a:string, b:number];
x = ['abc', 100] //okay
x = [12, 'hello']; //error
console.log(x[0]); //abc