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.