I got an email (a few weeks back - sorry - trying to keep up ;) from a developer who wants to use jQuery but doesn't really know JavaScript first. Having to learn how to walk before you run - I was curious as to what folks recommend for the best way to learn JavaScript? I'll list out a few options here and I'd love for my readers to comment on what they would recommend.
For me, I initially learned via documentation on Netscape's web site. That was back in 96 or so, but the developer network has come a long way since then. Oddly they list out the reference before the guide - I'd definitely start with the guide.
The other big help for me was the O'Reilly book JavaScript: The Definitive Guide. I have a few of the old editions on my bookshelf and will probably pick up this new 6th edition in PDF. You can find other good JavaScript-related ORA books as well.
Another book - although one that can at times be complex - is Object-Oriented JavaScript by Steven Stefanov. I reviewed that last year and made the point that it had quite a bit of good introductory material as well.
Another option are conferences. I had always assumed the jQuery conferences were for Ninjas only. (Ok, JavaScript Ninjas I mean.) And while the average technical level was quite high, the quality was excellent and I'd still recommend it for someone new. Just be prepared to take a lot of notes and ask questions. Of course, the excellent cfObjective that just ended also had multiple JavaScript sessions. I saw excellent ones from Ezra Parker and Elliot Sprehn that were both pretty darn enlightening.
Lastly - don't forget that all of this runs in a browser. If you've got a browser (and - um - you must) and a text editor that you have all the bare minimum tools you need. You may want to look at using Dreamweaver to help out - or the excellent Aptana editor as well.
Like most things - how you learn best is something you know. Books, online training, just playing, or a mix of all, figure out what works best for you and just make the time.
Archived Comments
I too am one of those that is trying to jump into jQuery without know a lot about Javascript. I found the book Smashing jQuery very helpful along with just finding some examples and breaking them apart to see what's what.
My favorite JS book is Javascript: The Good Parts by Crockford.
There is also the excellent Firefox add-in Firebug. This debugger for JavaScript makes life so much better.
I do now some fundamentals of JS/DOM - but not much more than that. Do you think that's enough for a "JQuery for Beginners" book?
This post from rey bango site might be useful too.
http://blog.reybango.com/20...
I never got a book, but I Google the heck out of things. If you know what you want to accomplish there is more than likely a tutorial out there showing you how to do it or at least something similar. Once I started tweaking it to do what I wanted I would get a better understanding of what was happening under the hood.
Of course, I always learned by doing things. If you like reading I suppose a book could be the way to go.
My personal favorite is John Resig's advanced JavaScript tutorial, assumes you know the syntax, covers a bunch of other good stuff: http://ejohn.org/apps/learn/
I've been using videos at Lynda.com for JS and JQuery.
do jQuery first, getting people to understand event-driven programming is too complex so start with something that makes it stupid easy
I actually *would* suggest studying OO JavaScript by Stefanov to get a good handle on things like closures, the prototype object, and constructors in JS. Crockford's JS:TGP is a great book, but I think it assumes a good amount of previous JS knowledge - it's rather succinct.
You can also get early access copies of Resig's Secret's of the JavaScript Ninja on Manning's website. O'Reilly's JavaScript Patterns book looks pretty good as well.
If he wants a more tutorial style introduction to JavaScript, have him/her check out:
Eloquent JavaScript: A Modern Introduction to Programming
Crockford has a 6 hour video at
http://oreilly.com/catalog/...
Lynda.com has titles on JavaScript and jQuery.
http://www.lynda.com
Sitepoint did a video series that has now moved to:
https://learnable.com/cours...
You may refer <a href="http://www.w3resource.com/j...">w3resource JavaScript Tutorial</a>. This has in depth lessons and ample of examples. They have a nice online practice editor too.
@Drew:
I disagree, it's better to learn what the underlying language is first before you dive into the simplified version. A programmer needs to be informed as to WHY jquery is a powerful library, not just to accept it because blogs say so.
Nothing drives me nuts more than seeing a webpage where my predecessor loaded a 20k file (jquery.js) for no other reason than to get an easy way to getElementById().
16 bytes versus 20,000ish.
Well, there's a progression...
For someone that's new to JavaScript, they should use $('#myID') and $('.myClassName').
If your site is so popular that you are starting to see degradation, then you may want to refactor.
I know that my sites never have that many users, so for me, I can't foresee ever using getElementById.
I just load jQuery from Google's CDN and consider it to be a part of the browser.
Doug, I couldn't agree more. I actually found this in code under development and kicked it back to be fixed:
var x = jQuery('#foo').attr('id');
document.getElementById(x).value = '';
My favorite quote about jQuery goes something like this (can't recall the source): "jQuery is this great framework that turns bad JavaScript programmers into worse jQuery programmers."
You have to learn to Wax On and Wax Off before you can try to Crane Kick.
I'll second Javascript: The Good Parts by Crockford and Eloquent JavaScript (http://eloquentjavascript.n....
Adrian, what was your recommended solution to them mixing jQuery and native JavaScript?
My solution would be to change document.getElementById(x).value = ''; to $('#x').val('');
I would venture to guess that if you removed the use of jQuery in your example, it didn't mean that jQuery could be taken out of the program.
If the JavaScript part of a program is so small that you don't have any references to jQuery in it, then it's merely a proof-of-concept.
If it's of any size at all, you're using jQuery somewhere else in there.
And if it's a proof-of-concept, you should still be using jQuery anyway because that means that you're learning the language.
Perhaps using getElementById is too simplistic an example. Anyone that has seen the minefield that events are (different commands depending on which browser) knows that a library HAD to have been written.
Wax on, Wax off? jQuery is a Makita Electronic Polisher-Sander!
Phillip:
I'd hate to admit it, but you're right. There are fewer and fewer pages these days that I'm using that don't use a JavaScript library at all. Eventually I might as well just load jQuery or whatever on my whole site since the overhead is marginal.
Still part of me is worried that jQuery won't be around for ever (perish the thought!) and I'd hate to be wedded to one library when there are others available that may be better--such as Mootools. Better to know the underlying language so you can jump across different libraries as the situation requires. But it's probably not necessary for JS newbies.
We've standardized on jQuery for the entire application. Until about 6 months ago, we only included the library when it was used on a page. I determined we were using it so often, there was no reason to not just load it all the time, so we did.
We told developers that ***if*** they knew how to do something with jQuery, they should. We have a LOT of old school document.formName.fieldName.value() going on and even worse, window.document . . .
In the case above, yes, all they needed to do was jQuery('#foo').val('');, but they didn't know that. They didn't know val(), they knew how to set a field value using the getElementById() method. They "just wanted to use jQuery" and there you go.
@Doug - I wouldn't worry about jQuery. Microsoft has included it as part of the .NET framework and Adobe is invested in it as well. Have you seen the integration with DreamWeaver? It's amazing.
Ray, correct me if I'm wrong, but at the recent jQuery Conference, they stated that ~44% of all sites are using jQuery. If you intend to be in web development right now, I think learning JavaScript first and jQuery second would greatly benefit anyone.
@Adrian: I don't remember the exact #, but it was pretty high (I'd consider anything over 25% as high).
Though I'm partial to The Definitive Guide the latest version of the JavaScript Cookbook covers the basics really well ...
http://oreilly.com/catalog/...
This one is a funny graphic about how people foolishly depend on jQuery. I stand by my assertion that people need to use jQuery and JavaScript intelligently.
http://www.doxdesk.com/img/...
(And hopefully this comment won't get filtered this time.)
@Doug: That's awesome. :)
The book I always recommend is QUE's Special edition, Using Javascript by McFedries - it is as entry level as I have seen and is full of example code. Easy to follow, easy to use and goes from variables to DHTML all in layman's terms - though I expect most folks will never need the DHTML stuff now that we have jQuery. ISBN: 0-7897-2576-2
It's about that bad! Crockford says to do this to add two numbers together: +a +(+b)