Last active
August 29, 2015 14:08
-
-
Save rochnyak-d-i/9f28d3ce55adaaa6e105 to your computer and use it in GitHub Desktop.
JS класс
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
var klass = function(Parent, props) { | |
var Child, i; | |
//новый конструктор | |
Child = function() { | |
if(Child.uber && Child.uber.hasOwnProperty('__constructor')) { | |
Child.uber.__constructor.apply(this, arguments); | |
} | |
if(Child.prototype.hasOwnProperty('__constructor')) { | |
Child.prototype.__constructor.apply(this, arguments); | |
} | |
} | |
//Наследование | |
Parent = Parent || Object; | |
inherit(Child, Parent); | |
//реализация методов | |
for(i in props) { | |
if(props.hasOwnProperty(i)) { | |
Child.prototype[i] = props[i]; | |
} | |
} | |
return Child; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment