Skip to content

Instantly share code, notes, and snippets.

@mde
Last active August 29, 2015 14:18
Show Gist options
  • Save mde/81b131ff6810ed7c4e0e to your computer and use it in GitHub Desktop.
Save mde/81b131ff6810ed7c4e0e to your computer and use it in GitHub Desktop.
Simple left-to-right mixin
var mixin = function () {
var args = Array.prototype.slice.call(arguments);
var target = args.shift();
var source = args.shift();
// We don't need no hasOwnProperty checks!
for (var prop in source) {
target[prop] = source[prop];
}
if (args.length) {
args.unshift(target);
return mixin.apply(null, args);
}
else {
return target;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment