P
Peter Michaux
Hi,
I'd like to have "class methods" inherit. Is there a way that isn't
copying properties from one function to another? I tried to do the
following with no luck.
function Person() {}
Person.classMethod = function() {
return 'classMethod';
};
Function.prototype = Person;
var Employee = new Function('alert("Employee");');
alert(Person.classMethod());
alert(Employee.classMethod());
I don't get an error when I assign to Function.prototype but I do see
the error "Employee.classMethod is not a function"
Any ideas?
Thanks,
Peter
I'd like to have "class methods" inherit. Is there a way that isn't
copying properties from one function to another? I tried to do the
following with no luck.
function Person() {}
Person.classMethod = function() {
return 'classMethod';
};
Function.prototype = Person;
var Employee = new Function('alert("Employee");');
alert(Person.classMethod());
alert(Employee.classMethod());
I don't get an error when I assign to Function.prototype but I do see
the error "Employee.classMethod is not a function"
Any ideas?
Thanks,
Peter