Skip to content

Instantly share code, notes, and snippets.

@H2CO3
Last active August 29, 2015 14:10
Show Gist options
  • Save H2CO3/ff70d3c5e88d600b6b7a to your computer and use it in GitHub Desktop.
Save H2CO3/ff70d3c5e88d600b6b7a to your computer and use it in GitHub Desktop.
I just read in the description of Google's Closure compiler that it "compiles JavaScript to better JavaScript".
// This is how H2CO3 writes a JavaScript to better JavaScript compiler
function compile(source) {
return ""; // no JavaScript is definitely better than some JavaScript
}
// Usage example
var exampleSource = "window.alert('foo');";
eval(compile(exampleSource)); // extra advantage: no more annoying alert windows!
@H2CO3
Copy link
Author

H2CO3 commented Nov 29, 2014

I'm glad I could help. Hopefully examining the generated code improved your JavaScript skills as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment