Why are jQuery's callback arguments inconsistent?

后端 未结 4 1105
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 07:21

A common pattern within jQuery is a method that takes a callback which is passed an element of an array and its index within that array. However, it seems completely random

4条回答
  •  时光取名叫无心
    2020-12-14 08:08

    According to https://learn.jquery.com/using-jquery-core/iterating/

    A word of warning: $.map() switches the order of callback arguments [when compared to $().map, $each() and $().each()]. This was done in order to match the native JavaScript .map() method made available in ECMAScript 5.

提交回复
热议问题