I think the first step is understanding that there is JavaScript (the language), then there is the browser's Document Object Model (DOM) and "HTML5" APIs. The JavaScript language is used in more places than just browsers (e.g. Rhino and Node.js) and doesn't change very rapidly. The DOM and APIs vary more across browsers and get new features with just about every browser release.
I'd recommend learning the language first, then the basics of the DOM and subscribing to the main browser's blogs to keep up with their changes.
If you just want a site to learn JavaScript, I'd highly recommend https://developer.mozilla.org/en/JavaScript (as other people have too). Mozilla's docs are top-notch. They're a wiki so sign up and help make them even better.
Best way to learn javascript is to type CTRL+SHIFT+I(in chrome I think its f12 in others) and look at the code. Chrome will even de-obfuscate it for you automatically. Step through the code, maybe write some script in the console, go through some resig tutorials.
I really liked looking at the underscore.js literate source but thats a little more theoretical than practical.
Also if you are just learning javascript you might as well learn jQuery because it will do a huge chunk of your basic practical needs. If you are learning javascript to really understand the language or build something super complex you may wanna watch the crockford videos and understand prototypes and those things. Otherwise jQuery will probably cover you.
I'd advocate learning JavaScript, learning the DOM and BOM, and only then learning a JavaScript framework like jQuery or YUI. Sooner or later you'll need to do some pure JavaScript development, and you'll need to know how to handle events or traverse the DOM without jQuery holding your hand. I say this as someone who has interviewed candidates for pure JavaScript roles who thought the terms jQuery and JavaScript were interchangeable.
Does anybody have a link to some good JavaScript exercises? One answer is "why don't you just try building something" but I personally learn better from progressing through exercises versus doing the "just build anything" or watching videos.
I just put up an interactive javascript tutorial. It starts simple then builds up to passing around functions, closures, continuations. Give it a try and let me know what you think. http://nathansjslessons.appspot.com/
Nathan, great tutorial! This is why I love HN. It reminds me of some of the interactive Ruby tutorials I've done. You've really got something going here.
"Test Driven JavaScript Development", Chris Johansen, might serve. Not many exercises, but it walks through some of the core JavaScript principles, using tests as a learning / exploring device. "Here's a test showing how the << this >> keyword works."
It also walks through several examples of test driven development, touching on design principles as it goes. It does a great job of walking through the practicalities forcing some design choices, and the implications of the alternatives.
I came away from this with a much better grasp of JavaScript, development process, and design principles generally. I don't think I've gotten more from any single book.
But I'm a newbie still trying to learn these things. More experienced folks may find the book tiresome.
Definitely a great book. Telling someone to just "build something" seems a bit much. Exploratory learning is good and all, but newbies need structure before they can try walking.
I'm currently learning Python and I can't agree more. There's a lot of macho-IRC-dweller attitude on the internet when it comes to learning a new language. People take the "If you teach a man to fish" argument to the extreme and end up confusing/discouraging people in search of some guide, some map to show them the way. No, documentation doesn't count when you can't read a lick of code.
That said, I'm currently reading Learning Python the Hard Way, which pushes you through a lot of information, step-by-step but not patronizing, and teaches you not only code, but how to be organized and on top of your code.
Eloquent JavaScript is comparable in that it's a book that has plenty of explanatory code snippets, but plenty of code exercises as well, and isn't a cookbook for web programming, but rather teaches the language for what it is. No jQuery/CoffeeScript stuff here, just straight-up JS as a language.
I have been looking to go beyond HTML/CSS and learn some JavaScript (HTML5 also) myself. Bookmarked the online book Eloquent JavaScript a while ago and I have been meaning to read it.
http://eloquentjavascript.net/
My local hackerspace, the Buffalo Lab is hosting the first meeting of the Buffalo JavaScript Club which is tomorrow. I am hoping this will jump-start me...
http://www.meetup.com/hackerspaces/events/25855541/
Sign up for Lynda.com watch the JavaScript videos a couple of times and then get started.
I found that when something gets turned into a video a lot of the un-necessary and verbose ness get taken out. Plus you get the advantage of the tutor putting the right emphasis on the right words.
I've summarised the most recommended resources here and on SO in a blog post at http://alicious.com/javascript-tutorials/ (aff links abound, sorry if that bothers you).
1-write lots of jQuery code. It has a dead simple api; hides most of the ugliness of the language; it slowly introduces you to closures (as opposed to Crockford, who loves them)
2-once you have that, then read Crockford
Please don't give out advice like this. I'm really fed up with having to deprogramme people who've written too much jQuery and don't actually know JavaScript, or worse, barely realise that there is such a language.
I appreciate that your suggestion is to learn jQuery and then go through a language reference, not to stop once you've done the jQuery bit, but trust me, that's just what most people will do.
jQuery is a very opinionated library, which is fine in and of itself, but that makes it a terrible introduction to JavaScript, precisely because it "hides most of the ugliness of the language", as you put it.
To understand why this is a problem, consider the following points.
1) jQuery is not the only DOM library out there. Prototype, MooTools, Dojo and YUI are just some of them. To be a good front-end developer one should know at least a couple, and be able to learn any of them. The easiest way to learn them is to know the language and just learn a library, rather than learning a bunch of different DSLs with perhaps a few unifying themes.
2) JavaScript is now used on the server as well, and to write server-side JavaScript one really does need to know the language.
3) If one ever wants to write anything beyond hacky little scripts—a real web application, for example—then one cannot get away with just knowing jQuery. Large applications must be structured. The rats' nest of callbacks that many jQuery programmers seem to think is sufficient and even appropriate application design will not scale to large codebases. The key skill here is knowing what sort of structure needs to be introduced and being able to use both use libraries which provide the necessary abstraction and write one's own where necessary.
I didn't say stop at jquery. But I do think its the easiest introduction to the language for someone with no functional background. If they stop there, that's they're fault. Once they learn an easy subset, its much easier to transition into the intermediate to advanced parts of the language. Regardless of programming language, if someone stops learning as soon as they can write a functional script, they're a bad dev.
I'd recommend learning the language first, then the basics of the DOM and subscribing to the main browser's blogs to keep up with their changes.
If you just want a site to learn JavaScript, I'd highly recommend https://developer.mozilla.org/en/JavaScript (as other people have too). Mozilla's docs are top-notch. They're a wiki so sign up and help make them even better.