Skip to main content

Bug Tracker

Side navigation

#11700 closed enhancement (duplicate)

Opened May 04, 2012 04:02PM UTC

Closed September 25, 2012 02:46PM UTC

Reduce Method

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

I think that it would make sense for there to be a reduce/fold method in jQuery. There is already an each and a map, and I think that reduce makes sense for pulling data from the DOM. It would allow for something like this:

total = $(".prices").reduce(function (a, b) { return a + b.text() }, 0)

I understand that this can be done by using multiple libraries (ie. Underscore and jQuery), however given all of the other methods which are available through jQuery (ie. map, each, filter, etc.) this does not seem to be outside the scope of this library.

Attachments (0)
Change History (3)

Changed May 04, 2012 04:39PM UTC by rwaldron comment:1

resolution: → plugin
status: newclosed

Thanks! This can be implemented as a plugin.

Changed September 25, 2012 02:45PM UTC by rwaldron comment:2

resolution: plugin
status: closedreopened

Changed September 25, 2012 02:46PM UTC by rwaldron comment:3

resolution: → duplicate
status: reopenedclosed

Duplicate of #1886.