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

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

                    if ( ops.unique )
                    {
                        // check whether it had been added before
                        if ( fn.name !== ” && hasName( fn.name ) )
                        {
                            return this;
                        }
                    }


                    ar.push( fn );


                    if ( ops.memory )
                    {
                        // after added , call it immediately
                        fn.call( this, lastArgs );
                    }
                }


                return this;
            };


            // remove a function
            this.remove = function ( fn )
            {
                if ( typeof ( fn ) === ‘function’
                    && fn.name !== ”
                    && ar.length > 0 )