So I'm learning prototype using javascript, and tried some code :
function Employee(name) { this.name= name; }
var m = new Employee("Bob");
var working= { isWorking: true };
Employee.prototype = working;
alert(m.isWorking);
Unfortunately, I get an undefined message, instead of the true value. Is there a reason to this result?
I have made several tests. I've concluded that reassigning the prototype object causes any previously created instances of the Employee class to be unable to access any properties found inside the newly assigned prototype. Is this accurate?
new). Changing the entireFoo.prototypeproperty object will not change this reference on the instance after. However, changes to theFoo.prototypeobject will be seen (because it's the same object), so e.g. if you instead didEmployee.prototype.isWorking = true;, you would see what you expect