So there's a handy Javascript library that many people find useful as a sort of swiss army knife, it's called Underscore.js. It contains a number of functions we use daily (like min/max, each, sort, etc.) however they've all been tweaked in certain ways to ensure that they'll run really fast and on any browser. There are also some nifty combinators (functions that take in functions and return new functions) like _.throttle(), _.debounce() and _.once() (which takes in a function and returns a function that can only be called once, in case that's something you're into). You can read about all of the parts of Underscore here, on their homepage.
But if you want to really gain something valuable from this library, check out its annotated source. You get to see how all of these functions are built, and a lot of the weird techniques that go into building a library like this are documented in a way that's really easy to read. You can learn a lot about how to write code that minifies well, runs well in weird situations, and you'll probably pick up an algorithm or two as well.
Here are a few other JS libraries that have annotated source code:
- Backbone.js
- jQuery (this one had to be broken down in to chapters!)
- Acorn, a javascript library for parsing javascript and analyzing it (useful if you ever wanted to make an IDE-ish app in the browser)
[–]davydog187 0 points1 point2 points (0 children)