Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I was going through one Backbone.js plugin in which I found the below piece of code.

callbacks : {
    search : $.noop,
    valueMatches : $.noop
}

What is the $.noop() function doing here?

like image 849
rrr Avatar asked Feb 05 '14 09:02

rrr


1 Answers

$.noop is an empty function so in your case it's returning an empty 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.

Documentation found here : http://api.jquery.com/jquery.noop/

like image 154
Anton Avatar answered Sep 18 '22 10:09

Anton