Ask HN: Learning to write good JavaScript
Check out the code in the open source project fabric.js http://fabricjs.com/ . It's written by Juriy Zaytsev who was a maintainer for prototype.js. I find the code useful for learning advanced object oriented JavaScript because:1) It's self contained. No dependencies on third party OO libraries or frameworks.2) The code is very readable.3) It's a canvas library, so it's fun to work with if you're into graphics and visualizations.4) You'll learn a lot about how many JS projects are built, documented, and tested, if you get it to build and the tests running on node.js.Here is what I would do:1) Check out the project and get it building.2) Read all the files in the util folder. You'll see a lot of methods added to Object and Array.3) Take a look at lang_class.js: https://github.com/kangax/fabric.js/blob/master/src/util/lan... This is how he does OO JS. It's very similar to John Resig's OO classes: http://ejohn.org/blog/simple-javascript-inheritance/ and somewhat different to prototype's classes: https://github.com/sstephenson/prototype/blob/master/src/pro...4) Then take a look at the base class: https://github.com/kangax/fabric.js/blob/master/src/object.c... and an inherited class: https://github.com/kangax/fabric.js/blob/master/src/line.cla...5) Search for instances of the "bind" method, and see how they're used.Of course, as you're doing all this, you'll need to experiment with simple language constructs in your browser's console to test what you think you know, and you'll want to read some chapters from a thorough JS book like, JavaScript the Definitive Guide http://shop.oreilly.com/product/9780596805531.doFinally, this is just a personal opinion, but I don't like Crokford's chapter on OO JS. I just don't think it presents your options well. If you decide to write a large project in JS using OO techniques, I think you'd be better off utilizing an OO library, compiler, or framework like TypeScript, Google Closure, Prototype or CoffeeScript, than you would charging forward armed with Crokford's chapter on OO.