0
comment
comment
on 12/11/2015 8:06 AM
How do you inherit from a “class” in JavaScript
Especially if you have a class that is a mix of constructor function and prototype methods and properties.
"use strict";
function getSeq(start){
return function next(){
return start++;
};
}
var getId = getSeq(1);
function Mammal(name){
var self = this;
var id = getId(); // private variable
this.getId = function(){
return id;
};
Object.defineProperty(this, 'name', { // we want name to be mutable
get:function (){ retu[...]