Witam
Mam taki kod
function Stor(val) {
this.value = val;
}
Stor.prototype.get = function () {
return this.value;
};
Stor.prototype.set = function (val) {
this.value = val;
return this;
}
function El(val) {
Stor.call(this, val)
this.value = val;
}
El.prototype = Object.create(Stor.prototype);
El.prototype.constructor = El;
//person = new Person("Bob");
let cacheStorage = {
first: new El(true),
second: new El(true),
}
cacheStorage.first.set("23") // set 23
Nie bardzo rozumiem ten fragment kodu
El.prototype = Object.create(Stor.prototype);
El.prototype.constructor = El;
Jak usunę El.prototype.constructor = El; kod będzie działał
jak zmienię El.prototype = Stor.prototype; kod działa
ale jak zrobię El.prototype = Object.create(Stor); wywali błąd.
Możecie mi rozjaśnić poco takie zabiegi się robi.