Why are jQuery's callback arguments inconsistent?

后端 未结 4 1113
爱一瞬间的悲伤
爱一瞬间的悲伤 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:20

    That's frustrated me also at times -- $.each is the one that I always mess up.

    I think it's due to different people/teams working on different parts of the framework. It's a community-driven framework, so nobody probably caught it early on and now that the framework is so wide-spread, they can't fix it without breaking 35% of all the sites on the Internet.

    I don't think it will be fixed -- at least that's my opinion/attitude. I'm just going to have to commit them to memory and hope for the best!

提交回复
热议问题