自己动手实现jQuery Callbacks完整功能代码详解

2020-05-18 08:43:17易采站长站整理

                                ar.splice( i, 1 );
                            }
                        }
                    }


                    return this;
                };


                // remove all functions
                this.empty = function ()
                {
                    ar.length = 0;
                    return this;
                };


                // check whether it includes a specific function
                this.has = function ( fn )
                {
                    var f = false;


                    if ( typeof ( fn ) === ‘function’
                        && fn.name !== ”
                        && ar.length > 0 )
                    {
                        for ( var i = 0; i < ar.length; i++ )
                        {
                            if ( ar[i].name === fn.name )