Function 类、对象和构造函数是否等效?

Function 类、对象和构造函数是否等效?,function,class,object,properties,ecmascript-6,Function,Class,Object,Properties,Ecmascript 6,现在JS有了类,我想知道这3个“站”之间是否有区别。是否有相同的/等效的? 在所有情况下,我都可以通过站访问标签。标签 //1 export class Station { public label: string; public code: number; constructor(label, code) { this.code = code; this.label = label; } } let station = new

现在JS有了
,我想知道这3个“站”之间是否有区别。是否有相同的/等效的? 在所有情况下,我都可以通过
站访问标签。标签

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

让我们这样说:在所有情况下,您都会得到一个带有label&code property;的新对象

最后,类被传输到函数中:

class A { 
    ...
}
被传输到smth,如:

var A = function A() { 
    _classCallCheck(this, A);
};
因此,您会得到一个等价的返回,但如何创建实例会有所不同;)

e、 g.
示例1和2->
新电台()

示例3->
Object.create(Station.prototype)