【发布时间】:2017-09-05 06:49:54
【问题描述】:
既然JS有class,我想知道这3个“站”之间是否有区别。有相同/等效的吗?
在所有情况下,我都可以使用station.label 访问标签
//1
export class Station {
public label: string;
public code: number;
constructor(label, code) {
this.code = code;
this.label = label;
}
}
let station = new Station("my label", "my code");
//2
function Station(label, code) {
this.label = label;
this.code = code;
}
let station = new Station("my label", "my code");
// 3
let station = { label: "my label", "code": my code }
【问题讨论】:
标签: function class object properties ecmascript-6