jussi-kalliokoski / blog

My personal blog
http://blog.avd.io
1 stars 1 forks source link

Multiple Inheritance in ES6 with Proxies #8

Open jussi-kalliokoski opened 11 years ago

domenic commented 11 years ago

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?

domenic commented 11 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.

jussi-kalliokoski commented 11 years ago

@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!

jussi-kalliokoski commented 11 years ago

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