Skip to content

Instantly share code, notes, and snippets.

@kicumkicum
Created March 29, 2016 04:46
Show Gist options
  • Select an option

  • Save kicumkicum/228dfccbead7236e0f19 to your computer and use it in GitHub Desktop.

Select an option

Save kicumkicum/228dfccbead7236e0f19 to your computer and use it in GitHub Desktop.
var inherit = function(a, b) {
function c() {
}
c.prototype = b.prototype;
a.superClass_ = b.prototype;
a.prototype = new c;
a.prototype.constructor = a;
a.base = function(a, c, f) {
for (var g = Array(arguments.length - 2), h = 2;h < arguments.length;h++) {
g[h - 2] = arguments[h];
}
return b.prototype[c].apply(a, g);
};
};
var Obj = function() {};
Obj.prototype.prop = 0;
var ChildObj = function() {};
inherit(ChildObj, Obj);
var obj = new Obj;
var childObj = new ChildObj;
console.log(obj.prop);
console.log(childObj.prop);
obj.prop = 1;
console.log(obj.prop);
console.log(childObj.prop);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment