This question already has an answer here:
- How does JavaScript .prototype work? 12 answers
I have one constructor function in my code. I have create instance of that constructor. In newly created instance I want to add value or function by using prototype method. But I getting error while doing this. Here is my code fiddle
function a(){
this.d=9
}
a.prototype.one=1;
a.prototype.two=2;
var j= new a();
j.prototype.three=3;
console.log(j)
In newly created instance I want to add value or function by using prototype method.
- Why? – thefourtheye Jan 8 at 10:04[[Prototype]]
of all Objects used for inheritance that references their constructor's prototype. – RobG Jan 8 at 10:07[[Prototype]]
for the internal property, but it's awkward to read and write. There must be a better name other than "internal prototype of an instance". – RobG Jan 8 at 10:16