ts中的数组对象

1. 使用泛型数组类型声明:


let arr1: Array<{name: string, age: number}> = [
  {name: 'ewr', age: 18},
  {name: 'test', age: 23}
];

2. 使用数组字面量方式声明:


let arr2: {name: string, age: number}[] = [
  {name: 'ewr', age: 18},
  {name: 'test', age: 23}
];

3. 使用Array构造函数声明:


let arr3 = new Array<{name: string, age: number}>(
  {name: 'ewr', age: 18},
  {name: 'test', age: 23}
);

你可能感兴趣的:(java,前端,linux)