Javascript objects inheritance -


i working on project whereby have noticed there multiple references same objects in different areas. have been reading on mixins , prototypal inheritance not sure 1 follow:

so current objects below need product inherit base class including function used everytime.

var base = function() {     this.id = 0;     this.refererer = null;     this.getcurrency = function() {         return "us"     } }  var product = function() {     this.name = "";     this.description = ""; } 

how can implement above use either mixins or prototypal inheritance?

var base = function() {         this.id = 0;         this.refererer = null;         this.getcurrency = function() {             return "us"         }     }  var product = function() {         this.name = "";         this.description = "";     }  product.prototype = new base(); // inheritance trick product.prototype.constructor = product;  var proobj = new product(); alert(proobj.id);   // 0 base class property "id" 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -