Skip to content

Instantly share code, notes, and snippets.

@grvgl
Last active August 29, 2015 14:24
Show Gist options
  • Save grvgl/b31b8324d8eec9984401 to your computer and use it in GitHub Desktop.
Save grvgl/b31b8324d8eec9984401 to your computer and use it in GitHub Desktop.
var JavaScriptSuperClass = function(count){
this.count = count;
};
JavaScriptSuperClass.prototype.increase = function(){
this.count++;
};
var JavaScriptSubClass = function(count){
JavaScriptSuperClass.call(this, count);
};
JavaScriptSubClass.prototype = Object.create(JavaScriptSuperClass.prototype);
JavaScriptSubClass.prototype.constructor = JavaScriptSubClass;
JavaScriptSubClass.prototype.decrease = function(){
this.count--;
};
var obj = new JavaScriptSubClass(10);
console.log(obj.constructor); //functin JavaScriptSubClass(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment