Created
March 12, 2009 13:08
-
-
Save greut/78050 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend(source, obj) { | |
for(var key in obj) { | |
if((obj[key].constructor === Array || typeof obj[key] !== "object") && obj.hasOwnProperty(key)) { | |
source[key] = obj[key]; | |
} else { | |
source[key] = extend(source[key]||{}, obj[key]); | |
} | |
} | |
return source | |
} | |
function A(name) { | |
this.name = name; | |
} | |
A.prototype.toString = function() { | |
return "A: "+this.name; | |
}; | |
function B(name) { | |
B.prototype.parent.apply(this, [name]); | |
} | |
B.prototype = extend(new A, { | |
parent: A, | |
constructor: B, | |
toString: function() { | |
return "B: "+this.name; | |
} | |
}); | |
function C(name) { | |
C.prototype.parent.apply(this, [name]); | |
} | |
C.prototype = extend(new B, { | |
parent: B, | |
constructor: C, | |
toString: function() { | |
return "C: "+this.name; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment