Created
September 17, 2015 16:03
-
-
Save andrIvash/61c806b41af8a1475d9e to your computer and use it in GitHub Desktop.
inheritance in javascript
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
//шаблон наследования в javascript | |
//C - child, P - parent , F - empty function | |
//uber - original ancestor | |
// C.prototype.constructor = C - a pointer to the constructor | |
function inherit(C, P) { | |
var F = function () {}; | |
F.prototype = P.prototype; | |
C.prototype = new F(); | |
C.uber = P.prototype; | |
C.prototype.constructor = C; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment