jQuery.noop() JQ Home  <<  Utilities  <<  jQuery.noop()

An empty function.

Description

The jQuery.noop() jQuery General utility method is used to pass around an empty function.

Shorthand version $.noop()

  • Useful for when you wish to pass around a function that will do nothing.
  • The jQuery.noop() jQuery General utility method, can be used as a single empty function instead of declaring empty anonymous functions all over the place.
  • Where optional callbacks are in place and no callback is given, the jQuery.noop() jQuery General utility method could be used instead.

Syntax

Signature Description
jQuery.noop()Used to pass around an empty function.

Parameters

None.

Return

An empty Function object.

An example of this would be where no callback is given such as in a plugin and we could execute jQuery.noop() instead, so its just like passing an empty function function(){}.


$(function(){
    options: {
        done: $.noop,
        fail: $.noop,
        always: $.noop
    }
});

Related Tutorials

jQuery Intermediate Tutorials - Lesson 9 - jQuery General Utilities