Slide 44
Slide 44 text
var createAndInit = function(source, props){
var slice = Array.prototype.slice;
var newObj = Object.create(source);
Object.keys(props).forEach(function(propName){
newObj[propName] = function(){
var zup = source[propName];
var boundZuper = zup ? zup(this) : null;
var newFunc = props[propName];
var args = slice.call(arguments, 0);
var allArgs = [boundZuper].concat(args);
return newFunc.apply(this, allArgs);
};
});
return newObj;
};