Skip to content

Instantly share code, notes, and snippets.

@f5io
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f5io/654e38b688cea60b643f to your computer and use it in GitHub Desktop.
Save f5io/654e38b688cea60b643f to your computer and use it in GitHub Desktop.
Angry functions in JavaScript.
/**
* 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