Last active
July 4, 2018 15:06
-
-
Save de314/c07ab5ff4be4157d59f0beb488bb409b 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 test() { return 'Hello, World!' } | |
function fromFunc(func) { return func.toString() } | |
function toFunc(funcString) { return new Function(`return ${funcString.toString()}`)() } | |
let tmp = fromFunc(test) | |
// tmp = "function test() { console.log('Hello, World!') }" | |
tmp = toFunc(tmp) | |
tmp() | |
// Hello, World! | |
function _alert(m) { alert(m) } | |
toFunc(fromFunc(_alert))('Hello, World!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment