Closed ghost closed 8 years ago
Instead of blowing away the prototype of your new class, why not use the other tools that Prototype provides:
Person.addMethods({
initialize: function(name){
this.name = name;
},
say: function(message){
return this.name + ': ' + message;
}
});
And then you should be able to do this.
Walter
thanks , Walter.
` var Person = Class.create(); Person.prototype = { initialize: function(name) { this.name = name; }, say: function(message) { return this.name + ': ' + message; } };
var guy1 = new Person('Miro1'); var guy2 = new Person('Miro2'); list=[guy1,guy2] for(var i in list){ var item = list[i]; item.say('hi'); // i just got : say is not a function } `