返回值:Booleancallbacks.has(callback)
判断函数列表中是否存在指定的回调函数。
-
1.7 新增callbacks.has(callback)
callback (Function) 将要查找的回调函数。
示例
使用 callbacks.has()
检查函数列表中是否包括指定的回调函数:
// a sample logging function to be added to a callbacks list var foo = function( value1, value2 ){ console.log( 'Received:' + value1 + ',' + value2 ); } // a second function which will not be added to the list var bar = function( value1, value2 ){ console.log( 'foobar'); } var callbacks = $.Callbacks(); // add the log method to the callbacks list callbacks.add( foo ); // determine which callbacks are in the list console.log( callbacks.has( foo ) ); // true console.log( callbacks.has( bar ) ); // false