【问题标题】:Difference between any[ ] and any[ ] = [ ]any[ ] 和 any[ ] = [ ] 之间的区别
【发布时间】:2018-01-09 07:45:51
【问题描述】:

在 TypeScript 中,stations: any[];stations: any[] = []; 有什么区别

export class RoleConfigurationComponent implements OnInit {
   stations: any[];
   stations: any[] = [];
}

谁能解释一下。

【问题讨论】:

    标签: javascript arrays angular typescript class


    【解决方案1】:

    stations: any[];

    上面表示 stations 属于 type array of any 但它的 NOT 已初始化

    stations: any[] = [];

    以上表示您是 initializing 站到 empty array

    【讨论】:

      猜你喜欢
      • 2018-08-23
      • 2021-01-30
      • 2020-12-09
      • 1970-01-01
      • 2020-11-15
      • 2017-10-19
      • 1970-01-01
      • 2019-06-07
      相关资源
      最近更新 更多