Created
September 21, 2009 23:18
-
-
Save fitzgen/190627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function quote(fn) { | |
return typeof(fn.name) === "string" ? | |
fn.name : | |
fn.toString() | |
.replace("function ", "") | |
.replace(/\([\s\S]*/, ""); | |
} | |
function funCall(fn) { | |
var args = Array.prototype.slice.call(arguments, 1), | |
mac = fn + "(", | |
arg, i; | |
for (i = 0; i < args.length; i++) { | |
arg = typeof(args[i]) === "string" ? | |
"'" + args[i] + "'" : | |
args[i]; | |
mac = mac + arg; | |
if (i !== args.length - 1) { | |
mac = mac + ", "; | |
} else { | |
mac = mac + ");"; | |
} | |
} | |
return mac; | |
} | |
eval(funCall(quote(alert), "hello")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment