Learning JavaScript

A .NET developer learning to appreciate JavaScript


I didn't care much for JavaScript for a while. It was occasionally useful for an animation, or some client side validation on a form, but not really essential. After all, the server was going to validate the input anyway, so this was just a fancy way of duplicating work.

JavaScript always seemed a bit messy. Often it was dumped in amongst HTML, sometimes there was JS code inside attributes. I was never really sure when variables were in scope and when they weren't. And there were strange goings on with == and ===.

But as time passed, I found myself needing to use it more and more. Suddenly everyone was going on about AJAX and websites started to become much more dynamic. So knowing more about this intransigent language started to seem like a good idea.

I realised that my trial-and-error approach wasn't going to work in the long run, but I was convinced this was because JS wasn't a very good language. So it took a while before I got any further.

It was only when I started reading JavaScript: The Good Parts, by Douglas Crockford, that my opinion changed, dramatically. It actually recommends avoiding certain parts of the JavaScript language, because they are poorly designed, and sticking with a subset of the language (the 'good parts').

If you stick to the 'good parts', and develop a good understanding of those, JavaScript is actually a very elegant, expressive language.

Now I've 'seen the light', I actually find JavaScript programming a lot of fun, and relish the opportunity to use it!

In this blog are a few small things I've learned from that book. Each of these small bits makes a big difference when I have to read or write JS.