1 Star 0 Fork 0

lyc458216 / TypeScript基础

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
01-10.数组和元组.ts 634 Bytes
一键复制 编辑 原始数据 按行查看 历史
lyc458216 提交于 2020-09-29 15:09 . init
// 数组
const arr: (number | string)[] = [1, "2", 3];
const stringArr: string[] = ["a", "b", "c"];
const undefinedArr: undefined[] = [undefined];
// type alias 类型别名
type User = { name: string; age: number };
class Teacher1 {
name: string;
age: number;
}
const objectArr: Teacher1[] = [
new Teacher1(),
{
name: "dell",
age: 28,
},
];
// 元组 tuple
const teacherInfo: [string, string, number] = ["Dell", "male", 18];
// 在读取 csv 文件时可以用到元组数据结构
const teacherList: [string, string, number][] = [
["dell", "male", 19],
["sun", "female", 26],
["jeny", "female", 38],
];
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/lyc458216/type-script-basics.git
git@gitee.com:lyc458216/type-script-basics.git
lyc458216
type-script-basics
TypeScript基础
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891