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: |
Description
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
Component: | unfiled → core |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
You're confusing jQuery.map() with jQuery().map()
http://api.jquery.com/map/
The args are reversed but it would break a lot of code to change it.