I'm a newbie with JavaScript and I'm facing a problem with constructor functions, my problem is that I can't overwrite an old function's property with a new one!
Below is my code:
function myFun() {
this.anotherFun = function() {
return true;
}
}
var myVar = new myFun();
console.log(myVar.anotherFun()); // returns 'true' as expected;
myFun.prototype.anotherFun = function() {
return false;
}
console.log(myVar.anotherFun()); // is returns 'true' why not 'false'?