Learning JavaScript

So you want to learn JavaScript huh? I can’t blame you, it’s a pretty rad programming language. Well lucky for you, it’s a really easy language to pick up and learn. You can get started with the language without spending a penny on a compiler, an IDE, or any instructional material. Heck, you already have a computer capable of running JavaScript. I know that because every modern web browser has one, and that’s how you are viewing this blog post.

I’m approaching this post as an introduction to JavaScript for someone who is already a programmer (novice or advanced, doesn’t matter). An introduction to programming would be an entirely different post.

Without further adieu…

Tip #1: Start by Reading the Wikipedia Entry

Yeah, we’re really swinging for the fences now, this is a tough one. You’ll find that entry here. Read it, thoroughly. It’s really helpful to get some background information on the language, the history, and various implementations of it. It’s helpful to understand that JavaScript is a standardized language, with many “engines” available to execute your code. There’s no single company behind the language. Also, forget that JavaScript has anything to do with Java. It doesn’t. It was just a horrible name for a language that wasn’t supposed to be very useful. Well, it turns out it was, and we all accept that it’s a horrible name and have moved on. C’est la vie.

Tip #2: Learn it Outside of a Browser!!!

I’m going to assume you have some experience with another programming language. Odds are likely it is PHP, Ruby, or Python. Those are all scripting languages, which means it isn’t compiled prior to runtime, instead it is read by an interpreter and executed on the fly. Well, JavaScript works the same way, there’s no compilation step you have to do prior to running a program. So, download Node.js and start writing some basic scripts. At this moment, Node.js only runs on OSX and Linux, so if you are running Windows, then ok… You can either visit jsbin.com or use the JavaScript console that comes built in to Chrome. Windows support for Node.js is coming soon though (late-summer 2011).

The reason I say learn it outside of a web browser is because you should approach JavaScript just like you would any other programming language. Only focus on its standard library to start. If you start toying with it in a web browser, you all of a sudden have access to the DOM and the BOM APIs, and then you’ll be distracted by learning HTML, CSS, which will likely be frustrating and lead you to a library like jQuery or YUI. Just don’t do it. Once you get comfortable with the syntax, scoping, and prototypal nature of the language, then proceed to use it inside of a web application.

Tip #3: Read Some Books

I highly recommend Eloquent JavaScript to start, because it’s a great book, and it’s free! After that, check out a few other of my favorites; The Good Parts, High Performance JavaScript, and Pro JavaScript Techniques. You can buy them all used off of Amazon for under $15 each.

Tip #4: Watch some videos

The YUI Theater is an excellent resource for anything front-end related. Some of it is focused on YUI, but there are quite a few videos that are just about JavaScript in general. The Crockford on JavaScript lecture series is amazing. Must watch!

Another video I came across recently was Alex Russell’s talk at Google.io 2011, “Learning to Love JavaScript“. It is probably the best introduction presentation to the language I’ve seen.

Tip #5: Get Involved in the Community

JavaScript meetup groups are popping up in every major city around the world, and there are many major JS-related conferences/events every year. Go to Meetup.com and search for “JavaScript” in your area. Attend a meetup, meet some fellow nerds, and ask them about their learning experiences with JavaScript. Don’t see one in your area? Create one! I did, twice.

If you really get into it, attend JSConf.us or JSConf.eu. They are the best JS-related conferences out there.

If you are anti-social and don’t want to get out and meet people, don’t worry, there’s a large community on-line as well. You can find us in #javascript on Freenode IRC. I usually hang out there (user: dgathright), as well as #yui, #jquery, #node.js, #html5, and many others. If you see me on there, ping me and let me know you saw this post and I’ll give you an internet high-five. Also, join the JSMentors mailing list. Its whole purpose is to help newbies like you learn the language we love.

Tip #6: Ignore W3Schools!

There is a plethora of ancient JavaScript tip sites that haven’t been updated in 10+ years. They often contain horrible, and sometimes incorrect, examples of JavaScript code. Instead, visit the Mozilla Developer Network’s JavaScript documentation. W3Schools is so bad, it even spurred W3Fools.com.

Tip #7: Be Curious

There are more discussions about JavaScript and code posted per day than time you have to actually read it. That means there is an unlimited supply of information out there about the language, seek it out.

Well, those are the tips that immediately come to mind. There’s quite a few more ideas, blog posts, tools, resources, services, etc… that I’d love to recommend, but you have more than enough to get started. Now go get coding!