JavaScript inheritance
Posted
by Tower
on Stack Overflow
See other posts from Stack Overflow
or by Tower
Published on 2010-05-30T15:06:54Z
Indexed on
2010/05/30
15:12 UTC
Read the original article
Hit count: 288
JavaScript
|object-oriented-design
Hi,
Douglas Crockford seems to like the following inheritance approach:
if (typeof Object.create !== 'function') {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
newObject = Object.create(oldObject);
It looks OK to me, but how does it differ from John Resig's simple inheritance approach?
Basically it goes down to
newObject = Object.create(oldObject);
versus
newObject = Object.extend();
And I am interested in theories. Implementation wise there does not seem to be much difference.
© Stack Overflow or respective owner