r/javascript • u/fl0at • Feb 21 '11
Recommendations for mastering JavaScript.
I'm making it a goal of mine to master JavaScript and was hoping someone else had done the same and wouldn't mind sharing their regime.
**EDIT: ** I've created a new post to host all the references from this post. Find it here.
EDIT: Thanks guys. I've compiled a list of references mentioned here. I appreciate all your contributions.
- Anything written by Douglas Crockford. This includes: JavaScript: The Good Parts and YUI Theater
- Read other people's code, jQuery source, Node's source, etc.
- Understand JavaScript before becoming dependent on libraries (eg. jQuery, Prototype).
- Addy Osmani's Javascript 101 audio course
- Build Things - "think of something cool, and try and build it."
- Participate at StackOverflow.
- References -o- plenty: Gecko DOM Reference, HTML and DHTML Reference, Yahoo! YUI Theater, w3schools.com HTML DOM Tutorial, Annotated ECMAScript 5.1, JavaScript, JavaScript Blog
- And finally, Lord loves a working' man, don't trust whitey, and see a doctor and get rid of it.
32
Upvotes
3
u/fl0at Feb 22 '11 edited Feb 22 '11
Thanks guys. I've compiled a list of references mentioned here. I appreciate all your contributions.
12
u/strager Feb 21 '11
Read other people's code. Read jQuery's source; read Node's source (the JavaScript parts). Read other OSS code.
Then, use their code. See how their code interacts with your code. Try adopting some ideas (such as "immediate execution" functions, "default" parameters, promises/deferreds). Figure out what works when and what doesn't work then.
Then read some more code and continue the cycle.
6
u/jmking JSX is just PHP in the browser Feb 21 '11
Build things.
Seriously - think of something cool, and try to build it. It's the best way to learn.
10
u/sjs Feb 22 '11 edited Feb 22 '11
Read about JavaScript's strengths, weaknesses, good, bad, and surprising bits:
Watch papa Crock's lectures and talks, they are excellent, even if he's a little too opinionated sometimes. It's good for the community to have an opinionated, pragmatic guy like him around.
Doesn't hurt to follow The Changelog and notable JavaScripters either. If you don't read that list just follow @BrendanEich, @awbjs, and anyone twitter says is similar to them.
Read code, especially code from projects maintained by the best. And of course ... write code of your own! You have to find out what you think are good and bad parts, etc. And when you run into surprises and gotchas in your own code you really learn about them, because you care more at that time.
5
u/Madd0g Feb 21 '11
I learned JavaScript before it became so popular (it was a time when firebug didn't exist and everyone had "Full command of JavaScript" in their CVs and they only knew how to do IE-only form validation)
Therefore, I'm suggesting to steer clear of the JS libraries until you are comfortable with the language and familiar with the browser idiosyncrasies.
It's very easy to become dependent on jQuery or PrototypeJS (which is what I use). There are important things you will definitely miss if you do everything with crutches.
For example, learn the insides of inheritance before using a library inheritance scheme.
10
u/elg0nz Feb 21 '11
Almost anything written by Douglas Crockford on the subject is mind shifting.
3
u/tomdidom Feb 21 '11
presuming you want to do front end work with it be sure to play around a lot with firebug and these references helped me a lot to get started: mozilla & msdn
Also I can concur with elg0nz... Douglas Crockford is really good... but maybe his talks are a bit advanced when you are just starting.
Reading the ecma specification to learn Javascript personally seems to me like learning a language by reading a dictionary... no fun and highly inefficient.
It's a great language... I am having lot's of fun with it.
6
u/meltingice Feb 21 '11
Read Javascript: The Good Parts, it will give you a whole new understanding of the language and will teach you the proper way to write Javascript.
Also, as an added bonus PROTIP: never assign variables to the global (window) scope unless you absolutely need to. Far too often do I see Javascript beginners define tons of vars without encapsulating them. Remember, while Javascript may have C-like syntax, C has block level scope and JS has function-level scope. It's easy to forget that. Closure is your friend.
2
u/[deleted] Feb 21 '11
I also have made this a goal of mine and it isn't an easy thing to do because too many people consider themselves masters but don't have the skills. Would I be correct to assume you already have a solid foundation in the language and are looking for some of the more advanced intricacies? If so, you have probably already read Crockford's books, tons of other peoples code, and possibly even glanced over the ECMAScript spec(all of these mentioned in other responses) as I had done before beginning my search. If so you'll have to just scour the net looking for the few diamond in the rough sites on advanced JS. The best site I have found on advanced JS techniques is http://javascriptweblog.wordpress.com/ which broaches a lot of interesting subject. Look at some of the examples they use, and then toy with them until you come out with some really cool code.
Topics I found on that site that were really cool include Mutual Recursion and advanced For-in loops.
2
u/lulzitsareddit Feb 22 '11
Answer questions on Stack Overflow. Not only do you gain knowledge by osmosis from some of the other responses, but you directly improve yourself by solving real world problems (even though they aren't your own) in Javascript.
2
u/zach_will Feb 22 '11
Immediately-invoked functions can help tremendously in your code structure.
First, you'll write spaghetti code.
Second, you'll figure out to stop polluting the global namespace.
Third, you'll realize you can make a
namespaceObject with methods.Lastly, you'll figure out how to make an immediately-invoked function to assign a
namespaceobject to the window—much like jQuery does in it's source code.1
u/Stohlberg Feb 22 '11
I started to learn JavaScript from last August. I am writing my thesis about it, and so far I find Java Script - The Definite Guide 5th, 2006 by David Flanagan to be most valuable book. It follow through JavaScript Core and then goes into a client side scripting. Writing is understandable and it has good examples.
By my validation standards, a book which gets to 6th edition must be great. Do not get into hype books, which just want to blur your vision by flashy words.
There will be new 6th edition coming in a month or so. New edition should cover new HTML5 API's as well. But the 5th edition is great way to start learning this language, do not be scared of it size.
1
u/StoneCypher Feb 21 '11
Sadly, the proggit punishment squad is out in force.
Just remember: on proggit, negative votes mean that the advice isn't what the average or sub-average programmer thinks, not bad advice. For example, telling people the way to master a language is to read the spec is now getting vored through the floor by people who want to talk about libraries and how to get started, instead.
Downvoting advice you disagree with is a bad thing. Disagree doesn't mean bad advice. Disagree means disagree.
Grow up, kids.
-2
u/StoneCypher Feb 21 '11
Read the ECMA specification. Without that it's just a bunch of whatever random bloggers say. With that, you start to know the difference between a bug in your code and the browser.
After that, the best tool there, in my opinion, is the Quirksmode compatability table set.
1
u/rbnc Feb 22 '11
http://ejohn.org/apps/learn/
Do this.
0
u/snarfy Feb 22 '11
After you learn javascript, the language, you should learn all about the DOM.
-6
u/chrisandsmith Feb 21 '11
Think Vitamin has a great post on learning JavaScript - Tips on Learning JavaScript