The Best Way to Learn JavaScript
basix

The Best Way to Learn JavaScript

Tutorial Details
  • Language: JavaScript
  • Difficulty: Beginner
This entry is part 2 of 5 in the The Best Way to Learn… Session
« PreviousNext »

Learning something new is scary. For me, the biggest issue with picking up a new skill is that I don’t know what I don’t know. Given that, it’s often useful to find a plan for learning whatever you’re interested in. That’s what this post is: your blueprint, your roadmap, your plan of action for learning JavaScript! You don’t have to worry about finding the best resources, sorting out the bad ones, and figuring out what to learn next. It’s all here. Just follow it, step by step.


Assignment 0: Understand what JavaScript Is and Isn’t

JavaScript is the language of the browser.

Before you actually begin learning JavaScript, take a minute to understand what it is and does.

JavaScript is not jQuery, Flash, or Java. It’s a programming language separate from all of those.

JavaScript is the language of the browser (not exclusively these days, though). It’s primary purpose is to add interactivity to an otherwise static page. In the browser, it’s not going to replace PHP or Ruby for you. It’s not even going to replace your HTML or CSS; you’ll use it in conjunction to them. Also, it isn’t as terrible to learn as you might have thought or heard.

One more note: you’ve heard about jQuery, which is probably the most widely-used JavaScript library. Or maybe you’ve heard about one of the other popular JavaScript frameworks, like Mootools, YUI, Dojo, and others. Where do these fit into the picture? Consider them a collection of JavaScript helper utilities; you’re still writing JavaScript when using them, but it’s heavily abstracted JavaScript. It saves you a ton of work.

You might even have heard someone say that you should start with jQuery (or another library) and learn JavaScript after. I respectfully yet strongly disagree. Get a good handle on JavaScript first, and then use libraries. You’ll understand what you’re doing much better; and, consequently, you’ll be writing much better JavaScript.


Assignment 1: Work Through the Courses at Codecademy.com

Codecademy is a relatively new website that bills itself as “the easiest way to learn how to code.” You’ll be the judge of that! Currently, there are only two course: “Getting Started with Programming” and “JavaScript Quick Start Guide.” This is an awesome way to dip your toes in the JavaScript pool. Very similar to the Try Ruby exercises, you’ll follow short lessons, writing code inside the browser and watching the results. All while earning points and unlocking achievement badges.

CodeCademy

If you’re already familiar with another programming language, you can probably start with the “JavaScript Quick Start Guide”; if this is your first time taking up programming (beyond HTML and CSS), then you’ll find the “Getting Started with Programming” course immensely helpful. Codecademy is free, but signing up is required.


Assignment 2: appendTo’s Screencasts

The folks at appendTo have a fantastic set of screencasts geared specifically for beginners. If you want to learn JavaScript the right (and easy) way, definitely work along with these lessons. Visual training is always a plus!

“Level up your skills with our on demand, pragmatic training solution. No signup required. No catch. No kidding.”


Assignment 3: Read A Good JavaScript Introduction

Eloquent JavaScript

Once you work through the courses at the Codecademy, you’ll want to get a more thorough introduction to JavaScript – an introduction that will introduce you to the all the types, operators, control structures, and more.

A handful of good introductions, if I may:

  • A Re-introduction to JavaScript – This introduction is on the Mozilla Developers Network, and certainly does the language justice. It’s a dense work, with almost as many code examples as paragraphs.
  • Eloquent JavaScript – This book, by Marijn Haverbeke, is available freely online, but you can also get it on Amazon if you’d like a hard copy. It goes beyond the MDN intro, because it covers not only the JavaScript language, but also coding style and using JavaScript in the browser. Also, “eloquent” isn’t an overstatement.
  • Getting Good with JavaScript – Okay, yes, this is my own book, but there’s another reason I’m including it here. It’s really pretty different from the other two intros I’ve listed here; I only cover what you’ll need to know to get up and running as quickly as possible. Also, it comes with over 6 hours of screencasts, so if that you’re thing, check it out. (And yes, this one costs.)

Assignment 4: Install and Learn Firebug (or the Developer Tools)

Firebug

Once you start working with JavaScript in the browser, you’ll want to install Firebug and get familiar with it. Firebug is a plugin for Firefox that assists you in building and debugging your web pages: think of it as the surgeon’s knife for web developers. Don’t use Firefox? Like Safari or Chrome better? No problem: check out the built-in developer tools, which are very similar to Firebug.

You can open the developer tools panel by pressing Option + Command + I on the Mac, or Control + Shift + I on the PC.

You’ll learn a lot by opening up your tool of choice and just clicking around while on one of your favourite websites. Here are a couple of resources that will get you up to speed:


Assignment 5: Read a Book

So now you’re familiar with the basics. However, there’s a lot more to learn. While I could recommend a list of books that would bankrupt you, I’ll keep it to four of the highest-quality books you’ll find anywhere:

These first two are general, in-depth JavaScript resources that take what you know from the introductions to a much deeper level; sure, they’ll be some overlap from the introductions, but not much: just enough to keep you comfy.

(Note: while all these books are available on Amazon, I’ve linked to the publishers’ websites, so you can check out the sample chapters available.)

  • Professional JavaScript for Web Developers – Written by Nicolas C. Zakas, this book could hardly cover more than it does. If you’ve seen any of Zakas’ work before, you’ll know he’s incredibly thorough. Besides covering the JavaScript language, this book will give you a good handle on using JavaScript in the browser.
  • JavaScript 24-hour Trainer – This awesome resource was put together by Jeremy McPeak, who writes for Nettuts+ as well. It’s not just a book: it comes with over 4 hours of video tutorials on DVD. There are 43 lessons, covering everything from syntax to coding guidelines and code optimization.

While those books are great for understanding the JavaScript language and how to use it in the browser, there’s a lot more to learn. And while those books do go into some patterns and practices, here are two books devoted to those subjects that I think you’ll find useful.

  • JavaScript Patterns – Written by Stoyan Stefanov. I just finished reading this book, and, boy, do I wish I had read it sooner. After reading the resources above, you’ll know how to write JavaScript, but this book will teach you how to organize it, an important skill that isn’t as common as you’d think.
  • JavaScript: The Good Parts – Written by Douglas Crockford. This little gem will explain what’s good and what’s bad about the JavaScript language.

Assignment 6: Build Something!

As you worked through the resources above, you should have been following along with the code samples: pulling them apart, and tweaking them to see what happens. But now it’s time to really strike out on your own. It’s time to actually build something.

So, what can you build? There’s a lot you can do. Here are a couple of ideas.

  • A Photo Gallery: Display a set of photo thumbnails and a main photo. When a user clicks a thumbnail, have the larger version of the thumbnail (not the thumbnail itself) replace the current main photo. Bonus points if you can overlay a caption coming from the thumbnail alt tag, or loop through the photos if the user hasn’t clicked one for a minute.
  • A To-do List: This might sound tougher than it is; but I’m not suggesting you build a full-fledged to-do application. Just have a text box with a button beside it; when you click the button, the entered text becomes an item in an unordered list below. Clicking on a list item removes it. It sounds simple enough, but there are several gotchas that it will be good for you to think about as a beginner.
  • An Animating Box: Animation is always tricky, but it doesn’t have to be complex. Have a div with some text in it, and several buttons above. One button can adjust the width; one, the height; and one, the background colour. The key is not to have the changes happen immediately, but over the course of, say, a second. Remember, Google is your friend, especially if you haven’t done any animation in JavaScript thus far.

I’m sure you can think of other projects that will be great practice. Of course, push yourself out of your comfort zone; that’s the only way to learn.

Also, be sure to refer to the JavaScript category here on Nettuts+ for a massive list of tutorials, at all skill levels.


Assignment 7: Begin Learning a JavaScript Library

Use a JS library

If you’ve come this far, you’ll probably realize that there are several things that are difficult to accomplish in a cross-browser way (or at all) in JavaScript. The biggest offenders are probably things like excessive DOM manipulation, AJAX, and animation. This is where a library comes it.

As I mentioned earlier, the point of a JavaScript library is to sugar down the painful stuff. Therefore, now might be the time to look at one. There are a ton to choose from, and I’ll let you decided which to experiment with. Whether it be jQuery or Mootools, YUI or Dojo, their respective sites will give you everything you need to get started. If you feel the need, give one a try.

Most Popular Libraries

While there’s certainly a countless number of libraries available, you should try to stick with a popular choice – at least at first.


Assignment 8: Keep up with the Masters

Drop what you’re doing, and subscribe/follow these developers. This is a requirement.

There are a ton of incredible JavaScript geniuses out there, who are always doing cool stuff that you don’t want to miss. Thankfully, our never-sleeping associate editor Siddharth has rounded up a list of ”33 Developers you MUST Subscribe to as a JavaScript Junkie. Drop what you’re doing, and subscribe/follow these developers. This is a requirement.

But you can do more. This fair website is often posting about JavaScript, so don’t go away. Also, check out the JavaScript Show, a podcast about the latest and greatest in the world of JavaScript. You might also want to sign up to the JavaScript Weekly email newsletter.


Conclusion

Thanks for reading! Hopefully, this plan can help you become a JavaScript fanatic. If you’re already familiar with JavaScript, can you recommend any other resources in the comments?

Tags: basix
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Andreas

    First :-)

    • Peter

      The illusion is astonishing, isn’t it?

  • http://andrewburgess.ca Andrew Burgess
    Author

    Hey guys,

    Also, just found this resource yesterday; it has some solid information about “the most quirky parts of the JavaScript programming language.”

    http://bonsaiden.github.com/JavaScript-Garden/

  • http://simonwjackson.com Simon W. Jackson

    Wow! Great roundup! and codeacademy.com looks awesome!

    I just wish there was a native Firebug plugin for chrome :/

    • http://andrewburgess.ca Andrew Burgess
      Author

      That’s how I used to feel. But the Developer Tools are really, really good now, even better than Firebug in some ways. Once you get used to the differences, I think you’ll find that you’re just as productive and happy with the Developer Tools as you were with Firebug.

      • Abhijit

        Chrome developer tools now are clearly better than Firebug for JS development. Firebug still rules for CSS and markups though.

    • andy

      chrome built-in developer tools has just about the same features as firebug. I do prefer firebug, but been using chrome since there memory usage problem kept killing my machine.

  • http://ralphwhitbeck.com Ralph Whitbeck

    Another great learning resource is the Learn site from appendTo http://learn.appendto.com

    • http://andrewburgess.ca Andrew Burgess
      Author

      Hi Ralph,

      I hadn’t seen that before; thanks for mentioning it! Looks like an excellant place to get started.

      • http://www.jeffrey-way.com Jeffrey Way

        I’ll add that to the article.

    • http://css-snippets.com Lisa C

      Thank you so much for this awesome list of resources. I’m a long time programmer, who finds javascript somewhat confusing, because it is so different from what I am used to (database programming).

      And thank you to the commenter who mentioned http://learn.appendto.com. This is an awesome resource that explains a lot of the nuances of JS that I have found confusing in the past.

      I will be checking out all the more intermediate books you mentioned also.

      Thanks!

  • JF

    Thank you for this great roundup !!

    Javascript Patterns is definitely a must read !

  • gno

    hey guys, anyone read both Zackas (‘Professional JavaScript for Web Developers’) and McPeak’s (JavaScript 24-Hour Trainer) books?
    Zackas is super hiped on the web and seems really good, BUT is 2 years (jan 2009) older than McPeak’s (dec 2010) and near double the size (840 pages vs 450) so i would prefer the newer one.
    then there’s the new version of famous “JavaScript: The Definitive Guide” (may 2011, 1090 pages) from Flanagan. This last edition got less love from js comunity, why?

    What you guys think?

    • http://www.wdonline.com Jeremy McPeak

      It depends on where you are in your knowledge in the language. Just beginning? Get mine. Been using JavaScript for a while and want a more thorough and complete take on the language? Get Zakas’

      I haven’t looked at Flanagan’s since the first edition, so I shouldn’t comment on it.

    • Andy

      Zakas is definitely the way to go for really professional development.

      If your interested in optimized javascript should look at videos and blog of paul irish

      http://net.tutsplus.com/articles/web-roundups/the-best-of-paul-irish-in-2011/

  • Ben Cole

    I’d love to read one of these for php, just knowing the best tried and tested resources for this sort of thing is a massive massive help. Thanks, and keep them coming!

    • http://www.jeffrey-way.com Jeffrey Way

      I’m making this a full series. So expect PHP soon.

      • India

        Good to know Jeffery. Andrew, this has to be one of the best resources on Javascript I’ve seen so far. I’m trying to step more into programming so making this a series will save me a lot of trouble. I can’t tell you how many hours I’ve wasted just trying to find a good collection of resources. Keep up the good work guys

  • http://www.wdonline.com Jeremy McPeak

    Thanks for the plug, Andrew!

    • http://laranzjoe.blogspot.com lawrence77

      Expecting “The Best Way to Learn ASP.NET”

      • http://www.wdonline.com/ Jeremy McPeak

        Well that’s easy. Watch the ASP.NET from Scratch series ;)

    • http://andrewburgess.ca Andrew Burgess
      Author

      No problem! Thank *you* for writing it. :)

  • LongCong

    Thanks for the stuff . Good job!

  • LongTS

    Thanks for the stuff, Good job

  • Austin

    Saying JQuery isn’t JavaScript is a bit controversial.

    • http://laranzjoe.blogspot.com lawrence77

      Where he says?

      i read “JavaScript is not jQuery” only

      • http://jacobbednarz.com Jacob Bednarz

        I am definitely a supporter of learning the core language before a library. Basic rule of mine is that if you cannot do it using the raw code, you shouldn’t use the library for it.
        It is imperitive to understand what is going under the hood and how things are interacting to give you the desired outcome. Not only will you be a better developer for it but your understanding will be far greater then that of those who only utilise libraries.

        This isn’t javascript specific, yet it is one of the most common repeat offenders ;) .

    • http://andrewburgess.ca Andrew Burgess
      Author

      I’m all about being controversial :)

      Seriously, though, I don’t think I said that jQuery isn’t JavaScript. I did say “JavaScript is not jQuery” (as Lawrence mentioned), and I did say that “you’re still writing JavaScript when using [a library].”

  • Seed

    Thank you for this Andrew. Good stuff.

  • http://jsvrocks.com/notebook Sandeep

    Awesome guide… Great stuff

  • Jamie

    Great post. I have been trying to learn more JavaScript this year and one of the hardest things I have found is knowing which learning resources( free or otherwise) to use in which order. As there is so much information out there I find myself jumping around a lot.
    Nettuts has some excellent posts but a lot of the JavaScript ones are JQuery. Could we have a post on: this is how to build something in JQuery but this is also how to build it in pure JavaScript, so we can compare the difference and learn that way.
    BTW the premium membership is well worth the money guys!

  • BenW

    I read “Head First JavaScript” from O’Reilly and thought it is a good introduction into JavaScript. Isn’t it? Should I read one of the other introductory books before I keep on learning with one of the books of assignment 5? Whether or not, thanks for the tips!

    • http://andrewburgess.ca Andrew Burgess
      Author

      I’m not familiar with that book, so I can’t comment; but if it was a good introduction, I’d say don’t worry about reading another introductory book. Move along :) You can always refer to one of the free intros if you run into something you don’t understand.

  • http://www.isitfriday.in Taxi-Kjell

    I am lazy. Can anyone recommend a javascript/jquery video tutorial?

    • http://andrewburgess.ca Andrew Burgess
      Author

      See Assignment 2.

  • http://goo.gl/K9dEc Nic da Costa

    Thanks for the great article! Really useful links and resources for those who are wanting to learn or even just refresh their basic knowledge.

    Another really great source for learning JavaScript which i would recommend to anyone, can be found right here on net tuts – http://net.tutsplus.com/tutorials/javascript-ajax/javascript-from-null-video-series/
    as well as all sorts of other quick tips and tricks that have been covered in previous posts (http://net.tutsplus.com/category/tutorials/javascript-ajax/?tag=basix).

    Keep up all the excellent work and awesome content guys!

  • Stoyan Deckoff

    Really nice:) I wanted to modify an existing extension for chrome for my own needs:) With lots of reading I managed to get the job done – but I had to learn javascript from scratch, JQ and WebSQL ;) I want to improve on the job I done, and one area I lack is how to use chrome debugger – so , this links should come handy :):) I needed a good book too – so I found some recommended, most tutorials out in the web are really basic :):)
    Thank for the good article, :)

  • http://www.vincent-stoltzenberg.com Vincent

    Great Info! Code Academy is looking awesome. Thanks for this!

  • zerazobz

    Many Thanks.

  • zerazobz

    Many Thanks.

  • http://www.acrazyidea.com|www.nicolefrolick.com Jafool

    Thanks so much for this article! I’m fairly competent with HTML and CSS and would like to learn PHP and JavaScript, but it’s hard to know where to start. Tuts are great and advice like this is a fried slice of gold!!

    Jeffrey – looking forward to the PHP one!

  • khinelay

    Thank you so much. I am start learning by your references

  • Nathan

    The link to the mootools library is incorrect:

    You put: http://www.mootools.com

    It should be: http://www.mootools.net

  • http://avey.de Way

    I really like the fact that you put libraries like jquery only at step 7 out of 8. People often forget that you have to know the basics before starting to use a library!

  • Okeowo Aderemi

    i’d like to really see a Dojo Tutorial from Nettuts as much as i know Dojo there’s a way Nettuts delivers tutorials that just makes it fun to read.

  • Alex

    The MooTools link is wrong! It should be http://mootools.net/

  • http://www.codylindley.com/ Cody Lindley

    When a person is ready… I’d also recommend.

    http://www.javascriptenlightenment.com/

    (Yes, I’m recommending my own book)

    • Justin

      I read it and loved it! Your book is what finally got me to fully understand in inheritance, prototypes, constructor functions and object objects … whew! Thanks for writing it.

    • http://damonsharp.com Damon Sharp

      I second this. Purchased it a couple days ago. Great book. Thanks, Cody!

  • Wang

    Can someone help me out on this problem on Codecademy?: http://www.codecademy.com/courses/javascript-intro/7#!/exercise/7

    SECTION 8: INTRO TO OBJECTS – Object notation nuances

    ==================

    // We’re trying to use WEIGHT_KEY to avoid having to
    // remember that the key that stores the weight information
    // is called ‘weight’.
    var WEIGHT_KEY = ‘weight’;

    var person = {
    name: ‘Ryan’,
    WEIGHT_KEY: 350
    };

    var weight = person.WEIGHT_KEY;

    ==================

    I set var weight = person[WEIGHT_KEY] but still get errors. In firebug I set weight = person['WEIGHT_KEY'] which retrieves 350

  • http://www.sequestermckinney.com Sequester McKinney

    Hey Andrew great stuff as usual. Can someone put something together like this for CSS too? Thanks so much.

  • http://snrky.com Snarky

    We’ve been discussing the best online resources/training resources at work. This is a nice list.

  • Scott

    Thanks for this, I began learning javascript a couple of years ago but got sidetracked and have resorted to using plugins and jquery in my projects. Now that my HTML and CSS skills are where I want them to be I decided to start learning javascript again and this post is exactly what I have been looking for. I’d really like to see more posts like this for other things like WP, CSS3, PHP and so on, but this will be more than enough for the time being. Thank you so much!! I do have one question though, aside from the resources that you provided, how do you feel about lynda.com for learning javascript?

  • http://brianswebdesign.com Brian Temecula

    Having done a lot of work with javascript in the last 6 months, I do agree with most of what is said here. One thing I wish I could find is a really nice tutorial (hint hint) on debugging with firebug. Using breakpoints, watches, step-over, step-into, etc is confusing to me.

  • Ben Cole

    Hi Andrew, on the verge of purchasing your book though I have a quick question – are the screen-casts and source files included in the hard copy version? Thanks!

    • http://andrewburgess.ca Andrew Burgess
      Author

      Yes they are; there will be instructions in the front cover on how to get the digital versions of the book (PDF, ePub, & Kindle), which I believe come with the source files. Then, p. 151 has the download links for the screencasts.

  • http://www.codehunterbd.wordpress.com Khairul Alam

    Thanks you so much for this important article to share.

  • http://www.liton-online.com Liton Arefin

    This important article will help many people. Codecademy is really awesome. I’ve achieved an award. I like it very much.

  • Dino Kraljević

    Thanks guys for awesome guide…

    All best!

  • Sirwan Afifi

    Thanks For Sharing

  • http://www.thoughtresults.com Saeed Neamati

    Great resources. I also recommend DailyJS (Just Google for it guys)

  • http://Techreuters.com Dheeraj

    I totally agree with you.
    Definitely, One should start with learning JavaScript initially, Not jquery. Because is the advance standard of JavaScript.

  • http://www.streamhead.com/ Peter

    I’d just like to mention I really like these types of posts (just like the Rails one). Keep them coming!

  • http://www.plug7.com.br Eliseu

    Other nice ways to try something new and fastly is the following websites:

    http://htmledit.squarefree.com
    http://www.jsfiddle.net

    I prefer JSFiddle because it’s easy to embed external sources and starting playing. Access GitHub, get some plugin’s source and modify it, see what happens! JavaScript will not affect our operational system, so there’s no fear.

    Nice post!

  • http://www.nikolaovcharski.com/blog/ Nikola

    Thank you for the great article

  • http://gregpettit.ca Greg

    I strongly disagree with your initial strong disagreement. ;-) Without writing a whole essay on the subject or quoting other experts in the field, I can state unequivocally as an educator that people who are more engaged are more likely to learn. There’s no compelling argument for “making people jump through hoops” at the beginning.

    The apparent logic might be, “learn the basis, then build on it.” But that argument is proven false simply by the fact that it’s a slippery slope. Before you know it, you’re drilling down and learning assembly language or binary. As soon as you have a slippery slope, you have an invalid argument.

    “Pure logic” aside, it’s just pride in our knowledge that makes us think it’s better to learn vanilla JS and build from there into the “shortcuts” of frameworks.

    Or on the flipside, even if we started with jQuery and eventually learned “pure” JS later, we might say to ourselves, “Man, it’s so much more efficient to just use basic functions in some cases! No bulky framework and faster execution in some cases! I have seen the light!” and feel that we wished we had known pure JS all along. But this is a revisionist approach… we’re able to see the benefits and understand that strong knowledge of “vanilla” JS is useful despite of or even because we started elsewhere. As it turns out, the starting point didn’t matter.

  • webdorq

    Codecademy needs a forum. I got stuck on the strings exercise, I need someone to allude to my stupidity and show me the way.
    // Examples of using indexOf.
    // 3.
    ‘foobar’.indexOf(‘bar’);

    // -1
    ‘foobar’.indexOf(‘baz’);

    // Modify the following function according to the comments inside
    // This function will be tested for correctness using a set of
    // example inputs

    function contains(str, substr) {

    // modify this code to return true if substr is a substring of str
    // and false if substr is not a substring of str
    var include = ‘str’.indexOf(‘substr’);
    if (include < 0) {
    print('false'); }
    else {
    print('true');

    };

    }

    • whiskeyface

      @webdorq I got stuck on this too with some rogue quotation marks that didn’t need to be there, here is what it accepted:

      function contains(str, substr) {

      if (str.indexOf(substr) === -1) {
      return false; // return false if substr is not a substring of str
      }
      else
      {
      return true; // Return true if substr is a substring of str
      }
      };

  • http://www.youtube.com/user/izvarzone AntoxaGray

    I learned some really basic stuff (arrays, variables, creating functions and while/if statements), but stuck when tried to make it work on web site… until I learned about jQuery, now I prefer not to use pure js at all, but a jQuery only (of course still using basic stuff like variables and arrays).

  • http://nnmportfolio.com Natasha McEachron

    Thanks, this is a great article! I’ve been thinking about learning some basic programming to use alongside HTML and CSS. These resources should help me along my way.

  • Tiziano

    Great list! I’ll wait for the PHP one :)

  • http://nicolahibbert.com/blogs/javascript/ Freelance JavaScript Developer

    Stoyan Stefanov’s other book – Object-Oriented JavaScript – is also a great read.

  • http://codendesign.blogspot.com nXqd

    Thanks for your great guide. I’d rather reading the book cause I’m experienced programmer, so I must be quicker. And I won’t read clearly about syntax, etc . I just want to know the core problem about memory, scope and javascript’s specialty only. We will know the syntax when we code :) It’s my experience.