Created
October 17, 2021 23:03
-
-
Save evinism/2ad57ce2690387950085f3e9430f6de3 to your computer and use it in GitHub Desktop.
cjsp4
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 uncomment(fn){ | |
const body = fn.toString().replace(/\/\//, ''); | |
return new Function(`return (${body})(...arguments)`); | |
} | |
function fn(a){ | |
// return a + 1; | |
return a | |
} | |
fn(1) // returns 1 | |
uncomment(fn)(1) // returns 2! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment