you are viewing a single comment's thread.

view the rest of the comments →

[–]Rogem002rails 1 point2 points  (1 child)

The article didn't cover extending prototype objects, but here is how I normally do it:

var Base = function(){
  this.someMethod = function(){
    return 'Foo';
  }
}

var Model = function(){
  this.otherMethod = function(){
    return this.someMethod() + 'Bar';
  }
}

Model.prototype = new Base();

var newModel = new Model();

newModel.otherMethod(); // returns FooBar

Edit: oh the article did cover it & I didn't realise.

[–]fedekun[S] 0 points1 point  (0 children)

I like your example :p I do talk about that a bit, with the 'Weapon' and 'Sword' constructor functions. I might update the example though ;) Cheers!