Underscore: A Functional Library for JavaScript
Underscore is a new library for functional programming in JavaScript. Those of us who enjoy Enumerable in Prototype will find it a welcome addition alongside other frameworks like jQuery.
Here are a few basic examples of the API:
_.each([1, 2, 3], function(num){ alert(num); });
_.map([1, 2, 3], function(num){ return num * 3 });
_.flatten([1, [2], [3, [[[4]]]]]);
There are also nifty functions for managing functions:
var greet = function(name){ return "hi: " + name; };
var exclaim = function(statement){ return statement + "!"; };
var welcome = _.compose(greet, exclaim);
welcome('moe');



