Skip to content

Instantly share code, notes, and snippets.

@jed
Created May 1, 2010
Embed
What would you like to do?
// async: manually sets the length of a function by wrapping it in another with the desired length
fab.arity = function( num ) {
var fn = function(_){ fn.apply( this, arguments ) }
, ends = [ "this(", ")" ]
, args = [];
while ( --num ) args[ num - 1 ] = "_" + num;
this( Function( "fn", ends.join( fn ).replace( "_", args ) ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment