Bug Tracker

Opened 13 years ago

Closed 13 years ago

#7008 closed bug (worksforme)

jQuery.map calls with elements reversed

Reported by: joost_m Owned by:
Priority: Milestone: 1.4.3
Component: core Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:


This correctly returns an array with the elements 'a', 'b' and 'c':

$(['a','b','c']).map(function(elem,index) { return this; });

This incorrectly returns the indices:

$(['a','b','c']).map(function(elem,index) { return elem; });

And this incorrectly returns the elements:

$(['a','b','c']).map(function(elem,index) { return index; });

So the arguments to the callback are reversed, if the documentation of $.map is to be believed.

Change History (1)

comment:1 Changed 13 years ago by dmethvin

Component: unfiledcore
Resolution: worksforme
Status: newclosed

You're confusing jQuery.map() with jQuery().map()


The args are reversed but it would break a lot of code to change it.

Note: See TracTickets for help on using tickets.