有两种方法可以在子级中调用父级构造函数。
var A = function A() {
this.x = 123;
};
var B = function B() {
// 1. call directly
A.call(this);
// 2. call from prototype
A.prototype.constructor.call(this);
};
B.prototype = Object.create(A.prototype);
B.prototype.constructor = B;
有没有一种情况会比另一种更安全/更好,或者它们总是相同的?