Last active
August 29, 2015 14:18
-
-
Save mde/81b131ff6810ed7c4e0e to your computer and use it in GitHub Desktop.
Simple left-to-right mixin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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