• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • callbacks.has()

    确定列表是否有绑定任何回调。如果回调作为一个参数提供,那么可以确定其是否在列表中。

    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