#12566 closed bug (wontfix)
$.each and ($.map or $.grep) callbacks - different function profiles but very similar
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
the function profile of the callback of $.each is different from $.map or $.grep, even though they are very similar. They all serve a very simmilar purpose and look very alike on other aspects as well, so it would make development easier if their function profiles would be the same, instead of interchanged:
jQuery.grep( array, function(elementOfArray, indexInArray) [, invert] ) jQuery.map( array, callback(elementOfArray, indexInArray) ) jQuery.each( collection, callback(indexInArray, valueOfElement) )
Change History (5)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Agreed, but they were defined years ago so there is no way to "fix" it without breaking a lot of code. So we will need to expect people to read the documentation.
comment:3 Changed 10 years ago by
Is there any chance that this could be a 2.0 feature? I understand that will contain many breaking changes anyway, why not change $(el).map, $.map, $.each and any other iteration methods to follow the ECMAScript standard of (index, element)?
This has always bugged me and 2.0 could be a great opportunity to get it fixed.
comment:4 Changed 10 years ago by
Nope, because that would make the 1.9 and 2.0 APIs incompatible. If you are using 2.0 you can just use the native EcmaScript methods anyway since the browsers it supports all have them.
properly aligned for easy observarion