jquery utility functions consistency
I have really been enjoying using jQuery, so thanks to all the devs
here. I have one main complaint- consistency in the api across
utitlity functions. When I use the utility functions, or their core
equivalents, I have to remember which comes first, the array element
or the index.
$.each(arr, function( index, element ){})
$.map(arr, function( element, index ){})
The natural way is to always put the element first for any iterating
function. This should also be true of any methods like filter.
Also, I consider the automatic flattening of arrays with the map
function a bug, not a feature. It would be better to pass in an
option for flattening.
$.map( [1, 2], function( element, index ) { return [ element, (element
+ 10) ] } )
I would expect [ [1, 11], [2, 12] ]
but instead it returns [1, 11, 2, 12]
In addition, $.grep should be renamed $.filter for naming consistency.
The utility functions are great resource, it would be nice if more
useful functions were exposed and documented in the library.