TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

JavaScript Mixins for grown-ups

51 点作者 northstar将近 14 年前

2 条评论

extension将近 14 年前
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 未加载
nxn将近 14 年前
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>