GWT can be Magical

The person or people responsible for the following must either be much more knowledgeable than I about JavaScript if statements, or simply more sinister. While pretty compiling one of my GWT modules today, I decided to take a peek at the generated source. As I was scrolling through the the module, my coworker pointed something out. This is what I found:

    if (function(){
      return ua.indexOf('msie') != -1 && $doc_0.documentMode >= 8;
    }
    ())
      return 'ie8';
    if (function(){
      var result = /msie ([0-9]+)\.([0-9]+)/.exec(ua);
      if (result && result.length == 3)
        return makeVersion(result) >= 6000;
    }
    ())
      return 'ie6';

After a few moments with a baffled expression on my face, he made the announcement that he would henceforth be performing all conditional expression evaluations within anonymous functions. I couldn’t agree more. I mean, what better way to mess with the person who will be reviewing, or worse yet, supporting your code? Now, I see what they did there in the IE 6 test. Quite the cleaver hack. Kinda. But to use the same mechanism for the IE8 test is just plain strange. Does anyone have a reason why this pattern might be desirable? I’ve since taken an oath to refrain from examining the generated crap, no matter how pretty it may proclaim to be, until I’ve come a bit further in my GWT mastery.

Reading - JavaScript: The Good Parts

I finished reading "JavaScript: The Good Parts" the other day. I read it cover to cover, in a linear fashion and I would say it has been highly rewarding. Now, when I say that, "I finished it," what I really mean is that I am finished building a mental index of the material, with a lightweight context that will help in JavaScript development. A few parts of the language, inheritance for example, have such subtle specifics that it will take a bit more practice before I can say that I have remastered the language and no longer need to reference the book. The best reason to read this particular text is the in-depth analysis of the languages features and suggested reasons to or not to use each.