12th September 2007

Stupid Javascript Mistakes

posted in Technology, Developers |

I’m working on a project that involves Javascript and I just got stuck for something like 2 hours. For some reason my .js file was mysteriously not running. IE was not showing any errors, just not running anything in the script. I tried using the debugger, but nothing. I tried putting an alert(”begin”) at the top and alert(”end”) at the bottom and nothing.

After spending far too long spinning in circles I thought of trying to run the file from the command line. Sure enough it spits out a syntax error. I had written
if(myobj.value ! "")
and left off the =. It should have been
if(myobj.value != "")

Still, it was very annoying that IE wasn’t spitting out any error messages. Even more annoying was how long it took me to catch this. I think I’ll use the cmd-line to syntax check Javascript more in the future.

There are currently 2 responses to “Stupid Javascript Mistakes”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On September 18th, 2007, Jonah Burke said:

    Firebug would have caught this: https://addons.mozilla.org/en-US/firefox/addon/1843. Or Venkman: http://www.mozilla.org/projects/venkman/. In my experience, you’re better off using Firefox for testing and debugging Javascript.

  2. 2 On September 18th, 2007, Alex said:

    True. I’m afraid I have to admit that this is for t a project that is IE only, hence the need to find the issues in IE.

Leave a Reply