Jump to content

Undefined


eTianbun

Recommended Posts

You are adding a property to the a object, not it's prototype. You could do:

function a() {   this.name='value';}

or

a.prototype.name='value';

If you want properties and methods to be part of every instance of an object, you need to add them to the prototype. Otherwise you will just create the property/method on the single instance of the object.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...