Last active
August 29, 2015 14:13
-
-
Save f5io/654e38b688cea60b643f to your computer and use it in GitHub Desktop.
Angry functions in JavaScript.
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
/** | |
* A quick implementation of this idea in JavaScript. | |
* https://www.reddit.com/r/shittyprogramming/comments/2sxbh9/program_with_all_obscure_c_features_ideas/cnu1qpm | |
*/ | |
function angrify(fn) { | |
return function() { | |
try { | |
fn.apply(this, arguments); | |
} catch(e) { | |
return e; | |
} | |
} | |
} | |
var angry = angrify(function() { | |
throw 'Hello world!'; | |
}); | |
console.log(angry()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment