Skip to content

Instantly share code, notes, and snippets.

@rochnyak-d-i
Last active August 29, 2015 14:08
Show Gist options
  • Save rochnyak-d-i/9f28d3ce55adaaa6e105 to your computer and use it in GitHub Desktop.
Save rochnyak-d-i/9f28d3ce55adaaa6e105 to your computer and use it in GitHub Desktop.
JS класс
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