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

前端 未结 9 745
故里飘歌
故里飘歌 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:20

    Real World Example (well almost):

    jQuery.fn.myAwesomeAjax = function(url, complete) {
      return jQuery.ajax(url || this.url)
        .complete(complete || jQuery.noop);
    };
    

    Use it instead of function (){}

提交回复
热议问题