javascript - Extending, instead of overwriting, the prototype -


in our current codebase, creating classes this

my_class = function(){   //do constructor stuff }  my_class.prototype = {   var1 : 'value',   var2 : 'value',   var3 : 'value'   .   .   .   //etc } 

there several classes like inherit super class. however, if this, end overwriting superclass' prototype.

my_super_class = function(){  }  my_super_class.prototype.generic_function = function(){   //all subclasses should have function }  my_subclass = function(){   //constructory stuff }  //inherit superclass my_class.prototype = new my_super_class();  my_class.prototype = {   //oops, there goes superclass prototype...   var1 : 'value',   var2 : 'value',   var3 : 'value'   .   .   .   //etc } 

is there better way my_class.prototype.val1 = 'value'; ... etc after inheriting superclass? follow convention our current codebase because short , point.

do use library or framework? if chances can use prototype's object.extend or jquery.extend.

what might find interesting new object.create ecma-262 5th edition.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -