Skip to content

Instantly share code, notes, and snippets.

@bittersweetryan
Created May 24, 2013 19:08
Show Gist options
  • Save bittersweetryan/5645817 to your computer and use it in GitHub Desktop.
Save bittersweetryan/5645817 to your computer and use it in GitHub Desktop.
var Widget = function(){
this.messages = [];
};
Widget.prototype.type='Widget';
var SubWidget = function( name ){
this.name = name;
};
SubWidget.prototype = new Widget();
var sub1 = new SubWidget( 'foo' );
var sub2 = new SubWidget( 'bar' );
sub1.messages.push( 'foo' );
sub2.messages.push( 'bar' );
var Widget = function(){
this.messages = [];
};
Widget.prototype.type='Widget';
var SubWidget = function( name ){
this.name = name;
Widget.apply( this, Array.prototype.slice.call(this) );
};
SubWidget.prototype = new Widget();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment