0
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 }