Bug Tracker

Ticket #10541 (closed enhancement: plugin)

Opened 4 years ago

Last modified 4 years ago

jQuery.map should not flatten out result array.

Reported by: kausikram@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7b2
Keywords: Cc:
Blocking: Blocked by:


jQuery.map has a behaviour of flattening out the result. this behaviour of jQuery.map is highly confusing while working with nested arrays and the work around for it (by making the return of the callback a single item array is hacky to say the least)

it would be helpful if jQuery.map takes an optional argument to override this default behaviour and return a nested array, if this parameter is set.

Example and test cases :  http://jsfiddle.net/tNYPQ/

Change History

comment:1 Changed 4 years ago by dmethvin

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

The existing behavior is exactly what we want for our internal use. Although this method is exposed for others to use, we don't want to add features unneeded by core since it adds to complexity, size, and run time. A more featureful implementation could be done as a plugin rather than added to $.map.

Note: See TracTickets for help on using tickets.