Open jussi-kalliokoski opened 12 years ago
Wait no, that doesn't make sense; you'll be able to hit Object.prototype
through the first of the prototypes. And actually this pattern prevents you from dispatching overridden Object.prototype
methods, e.g. Monkey.prototype.toString
.
@domenic Checking the obj
makes the prototype behave as it was just an object that happens to inherit from multiple objects, so you can assign/access methods to/in it without tempering with the inherited prototypes. But there's one mistake you made me realize, the empty object should have a null prototype, I'll fix that, thanks!
On second thought, I'll wait a bit before I will, I don't want people crashing their Firefoxes while reading my blog and trying it out: https://bugzilla.mozilla.org/show_bug.cgi?id=793160
Why do you check
obj
, given that it's always an empty object?Oh wait, I think I realized: because then you get access to
Object.prototype
's stuff. Interesting. Maybe worth adding to the post?