What's the difference between mixin() and extend() in Javascript libraries
问题 I'm looking through various libraries, and seeing extend() pop up a lot, but I'm also seeing mixin() show up. YUI has both mixins and extensions. What's the difference between these two concepts? When would I decide between a mixin and extending an object? Thanks, Matt 回答1: Mixins don't work with instanceof but extends do. Mixins allow multiple inheritance but by faking it, not by properly chaining the prototypes. I'll show an Ext-JS example but the concept applies to any class library that