What real purpose does $.noop() serve in jQuery 1.4?

前端 未结 9 764
故里飘歌
故里飘歌 2020-12-30 19:01

Pouring over the release notes regarding jQuery 1.4, I came acrosss $.noop() which is:

Description: An empty function. (added in 1.4)

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 19:06

    The only logical reason is if you're calling a function that does something AND calls another function, and you want the higher-level function to do its thing without calling a parameter function.

    Most of the jQuery functions optionally take a parameter function, so you don't have to pass one in. Maybe there's one or two where that's not the case -- or maybe it's to assist developers with their custom code that behaves like this.

提交回复
热议问题