Javascript 1.8 Fun

There are a lot of really cool new features from 1.6/7/8. A really nifty feature of 1.8 is the newreduce function.

You can see more of the features and more in-depth examples at the Mozilla Developer Center

PlainArray.prototype.sum = function() this.reduce(function(a, b) a + b); [6, 15, 107, 9].sum(); // 137
Add Comment