Skip to content

Instantly share code, notes, and snippets.

@MichaelXavier
Created December 15, 2014 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelXavier/6bee4640aa031841b0fc to your computer and use it in GitHub Desktop.
Save MichaelXavier/6bee4640aa031841b0fc to your computer and use it in GitHub Desktop.
reasonable use of defining functions in a loop?
function OOPShim() {
}
function proxyMethods(names) {
for (var i = 0; i < names.length; i++) {
var name = names[i];
OOPShim.prototype[name] = function(a) {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift(this.state);
return FunctionalAPI[name].apply(this, args)();
};
}
}
proxyMethods('foo', 'bar', 'baz');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment