Skip to content

Instantly share code, notes, and snippets.

@obenjiro
Last active October 13, 2015 14:28
Show Gist options
  • Save obenjiro/4210313 to your computer and use it in GitHub Desktop.
Save obenjiro/4210313 to your computer and use it in GitHub Desktop.
Function builder - allows to save more space (74 chars)
//Function builder
var functionBuilder = function (args, body) {
var argsAsString = args.split(',').toString();
return eval('(function(' + argsAsString + '){' + body + '})');
}
//minifed (74 chars)
var f=function(a,b){return eval("(function("+""+a.split(",")+"){"+b+"})")}
//sample usage
f('event,a,b,c,d,e', 'return 1')();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment