Сообщение от Erolast
|
И не буду, пример неверен. Надо так:
function inherits(Child, Parent) {
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
}
function Interface(){};
function Class(){};
inherits(Class, Interface);
Interface.prototype.someValue = 1;
Class.prototype.someValue = 2;
alert((new Interface()).someValue);
alert((new Class()).someValue);
|
Кстати, а нельзя вместо объекта во 2-ом аргументе create, просто написать вот так:
Child.prototype.constructor = Child;