I created 2 instances of a prototype, changed a function in prototype, changes reflected in both the instances (Great). However, when I modified the prototype by removing the function, the function still existed for the existing instances.
function A() {
this.name = "cool";
}
A.prototype = {
howCool: function() {
return this.name + "er";
}
};
var a1 = new A(),
a2 = new A();
a1.name = "hot";
//line1
console.log(a1.howCool());
//line2
console.log(a2.howCool());
A.prototype = {};
//line3
console.log(a1.howCool());
//line4
var a3 = new A();
console.log(a3.howCool());
Line 1 and 2 are working as expected and after setting the protoype back to empty, line 4 is showing undefined which is expected. line 3 however is still showing the function definition.