Skip to content

Instantly share code, notes, and snippets.

@kazuho
Created March 10, 2012 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kazuho/2011480 to your computer and use it in GitHub Desktop.
Save kazuho/2011480 to your computer and use it in GitHub Desktop.
function Base(x) {
// override properties in prototype if necessary
if (arguments.length == 1) {
this._x = x;
}
}
Base.prototype = {
_x: 1
};
function Derived(x) {
// override properties in prototype if necessary
if (arguments.length == 1) {
Base.call(this, x);
}
}
Derived.prototype = new Base(3); // default value of _x is 3 for Derived
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment