07. Species Pattern
function SpeciesConstructor(O, defaultConstructor) {
const C = O.constructor;
if (C === undefined) {
return defaultConstructor;
}
if (!isObject(C)) {
throw new TypeError();
}
const S = C[Symbol.species];
if (S === undefined || S === null) {
return defaultConstructor;
}
if (!isConstructor(S)) {
throw new TypeError();
}
return S;
}Symbol.species
Symbol.speciesLast updated