Mixin

by southerd

JavaScript

function mixin(target, source) {
    for(var key in source) {
        if(source.hasOwnProperty(key)){
            target[key] = source[key];
        }
    }
}
var thing1 = {name: "thing", number: "one"};
var things = {doMischief: function(){console.log("Mischief has happened!");}};
mixin(thing1, things);
thing1.doMischief();