Using JavaScript in strange ways

AppFog had a competition a few years ago to make an app which printed “Happy Birthday, OpenStack.” I submitted an entry, but did not win. The winner was someone that used AsciiArt. Oh well. I still think my entry deserved notice, as it uses a few subtle features of JavaScript. Here is the code:

What this does:

  • Reads in its own source code and retrieves the poem from the head
  • Uses text in the poem to reference functions stored in objects returned from require calls.
  • Uses bit shifting; did you know JS had bit shifting?
  • Heavy usage of the l33t hacker number 1337

If you run this app and visit /, it will print “Happy Birthday, OpenStack”. You can see the src at /src. Changing the poem in the comments of the JavaScript code will break the application.