Jquery_2.1.0_ Diary 5.2

Source: Internet
Author: User

$. Method
(1) $.merge (first, second)Merges two arrays or class arrays, adds the second array to the end of the first array
(2) $.grep (Elems, callback, invert) use callback to filter Elems if invert is set to True. Returns an array of elements that retain the callback return value of false. If invert is set to False, callback returns an array of elements that return a value of true.
Test_script var arr = [ ' A ' , ' B ', ' C ']arr = $.grep (arr, function (){      //arguments[0] is elem,arguments[1] for Elem in arraythe index in       if (arguments[1] = = 1) {            return  false;      }  Else {          return  true;      }   },  true );alert (arr[0]);//' B '

(3) $.proxy (FN, CONTEXT[,ARGS1][,ARGS2] ...)executes the environment for the FN binding context, returning the object after the agentTest_script function A () { alert (arguments.length)//3Alert ( This .  JQuery); //11   }    var proxy = $.proxy (A, {JQuery: ' One ' }, ' Arg1 ', ' arg2 ');Proxy (' args3 ');   $.proxy Source   Proxy: function(FN, context) {               var tmp, args, proxy;
              //If parameter context is a string, fix parameter               if (  typeofcontext = = ="string" ) {TMP = fn[context];                     //execution Context first parametercontext = fn;                     The //function is the property value of the first parameter named second parameterfn = tmp;              }
              //Quick Check to determine if target was callable, in the spec              //This throws a TypeError, but we'll just return undefined.               if (!jquery.isfunction (FN)) {                       return  undefined ;              }
              //Simulated bind               //2 parameters after the argument as the agent after the objectargs = slice.call (arguments, 2);              //Agent post function proxy = function() {                      return fn.apply (Context | | This, Args.concat (slice.call (arguments)));              };
               //Set the GUID of unique handler to the same of original handler, so it can be removed              //Set the unique identifier of the proxy functionproxy.guid = Fn.guid = Fn.guid | | jquery.guid++;
               return proxy;        },

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.