// 数组和元素 const arr: (number | string)[] = [1, "2", 3]; //数字或者字符串 const stringArr: string[] = ["a", "b", "c"]; // 字符串 const undefinedArr: undefined[] = [undefined, undefined]; //不能存其他的 //写法1 const objectArr: { name: string; age: number }[] = [ { name: "lll", age: 12, }, ]; // 或者写法2 type User = { name: string; age: number }; const objectArr2: User[] = [ { name: "llll", age: 12, }, ]; // 类型别名 class Teacher { name: string; age: number; } const objectArr3: Teacher[] = [ new Teacher(), { name: "www", age: 12, }, ]; // 元祖tuple const teacherInfo: [string, string, number] = ["ll", "xscs", 15]; // 用处:csv