Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My background is mainly strongly typed languages (java, c++, c#). Having recently gotten back to a bit of javascript, I found it a bit annoying that if I misspell something by accident (for example I'll type 'myvar' instead of 'myVar') my entire script crashes. The browser itself most of the time doesn't even tell me I have an error, my program will just be blank, etc. Then I have to hunt down my code line by line and find the error which is very time consuming. In the languages I am used to the compiler lets me know if I made a typo.

My question to you is, how do you overcome this issue in scripting (javascript)? Can you give me some tips? (this question is mainly aimed at people that have also come from a strongly typed language).

Note: I mainly use the terminal/VIM ... this is mainly b/c I like terminal and I SSH alot too

share|improve this question
*misspell ..... – Jonathan Khoo Mar 13 '11 at 1:30
argh.........;) – foreyez Mar 13 '11 at 1:38

Most browsers should have options to allow you to turn on javascript errors... I've been away from web development for a little bit so I haven't looked recently. If you use Firefox (or are willing to) there is a plugin called Web Developer Tool bar that is GREAT for things such as javascript and css debugging.

share|improve this answer

The right solutions are generally to have unit tests, and to use some linting program.

With JavaScript I can recommend for the latter. You'll have to code your JavaScript according to the Google Style Guide, but that's not a particularly bad style guide for JavaScript.

share|improve this answer

You should really try out a unit testing framework for Javascript. It will catch a lot of these irritating errors that you can spend a lot of time chasing down.

I'd recommend Jasmine:

share|improve this answer

Have you tried eclipse? I have seen the type of capability that you are talking about in it. The plus is that you can download plugins for multiple languages to give you what you are asking for. When I have used it in the past it almost feels like Word spell/grammar check is running and underlining the suspicious pieces of code.

Personally I have seen it help with Java/Python/C++.

Also you might want to go look for a lint program for the language you are using. They traditionally find a lot of these types of errors.

share|improve this answer

JavaScript makes up for the errors you mentioned by being very interactive and easy to test so whenever the program comes tumbling down it does so pretty quickly and painlessly so in practice it is not a very big issue. So whenever you write a few lines fire up the browser and see what happens. My tool of choice is firebug on firefox but any other developer tool offered by the other browsers would work as well. I basically write all the code from the firebug console by testing bits and pieces as I go along. It's been working pretty well so far.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.