jQuery.Callbacks - Removing anonymous function callbacks <p>After adding a callback function to $.Callbacks(), I want to remove it again:</p> <pre><code>var callbacks = $.Callbacks(), foo = function() { console.log('Hello world') }; callbacks.add(foo); callbacks.fire(); // logs 'Hello world' callbacks.remove(foo); callbacks.fire(); // nothing to trigger, removed perfectly </code></pre> <p><strong>So, that works</strong>, but now I want to add an anonymous function, like so:</p> <pre><code>callbacks.add(function(){ console.log('Hello anonymous world') }); callbacks.fire(); // logs 'Hello anonymous world' </code></pre> <p>Looks fine, <strong>but I can't remove the function anymore</strong>:</p> <pre><code>callbacks.remove(function(){ console.log('Hello anonymous world') }); callbacks.remove(); callbacks.fire(); // still logs 'Hello anonymous world' </code></pre> <p><strong>Is there a way to overcome this?</strong></p>