0

extending this link What is the use of jQuery.noop() function?

You can use this empty function when you wish to pass 
around a function that will do nothing.

This is useful for plugin authors who offer optional callbacks; 
in the case that no callback is given, something like jQuery.noop could execute.

what does it mean by plugin authors who offer optional callbacks, an example will do.

Community
  • 1
  • 1
user2167582
  • 5,986
  • 13
  • 64
  • 121

1 Answers1

1

For example, a plugin with optional done fail and always callbacks:

options: {
    done: $.noop,
    fail: $.noop,
    always: $.noop
}

now the plugin author can assume that there is a callback defined for each even if the developer using the plugin doesn't pass one.

https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L577

Kevin B
  • 94,570
  • 16
  • 163
  • 180