Created
June 4, 2014 20:37
-
-
Save jwerle/2c4f3fdd0ea46dcb48ea 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 s (fn, args) { | |
var code = null; | |
var f = null; | |
args = args.map(function (a) { | |
return 'function' == typeof a ? a.toString() : a; | |
}); | |
args = JSON.stringify(args); | |
code = '(' + fn.toString() +').apply(null,'+ args + ')'; | |
f = new Function(code); | |
return f; | |
} | |
function log () { | |
var a = [].slice.call(arguments); | |
var f = Function('('+ a.pop() +')()'); | |
console.log.apply(null, a); | |
f(); | |
} | |
var p = s(log, ['hi', 'hey', 'hello', function () { console.log('omg'); }]); | |
p(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment