JavaScript sucks ass, part one million

In the spirit of Bob Ippolito's JavaScript Sucks posts, here is one of my own. Sit down and let me tell you a tale about the little language that is so close to being good, yet so far...

Recently, I changed jobs. I joined a company called slide, which is building a hybrid photo sharing application using a combination of fat client and rich web technologies. In my drive to create responsive web applications I have been exploring techniques which make heavier and heavier use of client-side JavaScript. I now find myself doing less and less Python and more and more JavaScript rendering code.

I don't really mind this too much. I think JavaScript is a reasonable language, with reasonable anonymous function syntax, real closures with mutable parent scopes, and prototype inheritance (with the most bizarre implementation that unfortunately renders it almost unusable). However, every once in a while I hit some issue which drives me absolutely insane trying to debug.

Here is what I ran in to. The following:

{'foo': 1}

Is not valid syntax. However, the following:

foo = {'foo': 1}

Works fine. I ran in to this issue while trying to eval constructed strings of javascript. Even though eval returns a result, giving it a single JavaScript object literal results in an exception. Tacking on an assignment at the beginning fixes the issue. Ugly.