function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError(
"Super expression must either be null or a function, not " +
typeof superClass
);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass)
Object.setPrototypeOf
? Object.setPrototypeOf(subClass, superClass)
: (subClass.__proto__ = superClass);
}
above is the transcoding effect of babel, where this code
if (superClass)
Object.setPrototypeOf
? Object.setPrototypeOf(subClass, superClass)
: (subClass.__proto__ = superClass);
question: 1. I think this code can be regarded as implementation inheritance without adding it. It seems that there is no code to set _ _ proto__ to the constructor of the subclass in the elevation. What"s the difference between setting and not setting?
- _ _ proto__ remember that there are only objects? Although everything in js is an object, how do you understand the _ _ proto__ of its _ _ proto__, function in an instance of the common story new?