TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

JavaScript Mixins for grown-ups

51 pointsby northstaralmost 14 years ago

2 comments

extensionalmost 14 years ago
Note that the way mixins generally work in languages with first class support for them is with multiple inheritance. That is, mixins are included by reference and, in a dynamic language, changes to the mixin affect objects that have already been extended.<p>JavaScript can't do multiple inheritance and so you have to hack mixins by copying. This sucks when you want to e.g. extend an Enumerable mixin because.. well, you can't.
评论 #2620968 未加载
评论 #2620438 未加载
评论 #2620864 未加载
nxnalmost 14 years ago
This post inspired me to try and create the mixin pattern in C# with interfaces, extension methods, and optional generics. Probably been done before, but meh, here's the result: <a href="http://pastebin.com/ZiddNDSi" rel="nofollow">http://pastebin.com/ZiddNDSi</a>