I've never been a great JavaScript wizard or user even, but recently I've began to use jQuery. jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML. jQuery is the JavaScript framework used by Drupal, hence my connection to it.
I must say, I'm quite impressed by the power JavaScript has. I never knew it had so many possibilities. Things I used to write complex PHP snippets for can be simply done using JavaScript which is great for static HTML websites.
For example, let's say you have a table and you want to change the background color for odd table rows. You could change the background color for each row, but if you want to change the color later on you need to replace quite a few elements. Using Find-And-Replace-All might be a solution, but let's forget about that for now. The best solution is to add a class. But what if the person adding new elements doesn't know HTML and you don't want to bother them with adding classes to the correct table row.
Assume the table has a class called sortable and you have a class in your CSS file called odd.
That's it. All there is to it. It will add the class odd to the odd table row elements. Counting is done by the build in JavaScript element counter.