Bug Tracker

Modify

Ticket #11700 (closed enhancement: duplicate)

Opened 13 months ago

Last modified 8 months ago

Reduce Method

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

Description

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.

Change History

comment:1 Changed 13 months ago by rwaldron

  • Status changed from new to closed
  • Resolution set to plugin

Thanks! This can be implemented as a plugin.

comment:2 Changed 8 months ago by rwaldron

  • Status changed from closed to reopened
  • Resolution plugin deleted

comment:3 Changed 8 months ago by rwaldron

  • Status changed from reopened to closed
  • Resolution set to duplicate

Duplicate of #1886.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.