Posts tagged javascript
Posts tagged javascript
A simple convenience function for adding together an array of numbers.
//
// Iterates over an array of numbers and returns the sum. Example:
//
// _.sum([1, 2, 3]) => 6
//
_.sum = function(obj) {
if (!$.isArray(obj) || obj.length == 0) return 0;
return _.reduce(obj, function(sum, n) {
return sum += n;
});
}
I’ve just pushed out a new release of CalendarView, my lightweight JavaScript calendar widget for the Prototype framework. This release includes numerous cleanups and bug fixes as well as support for Internet Explorer 8.
Release Notes
Download