Makearray: Class array to True array
Merge: Combine arrays or go to special JSON
Examples of use (external use):
var adiv = document.getelementsbytagname (' div ');
Console.log ($.makearray (Adiv)); [Div,div,div]
var str = ' Hello ';
Console.log ($.makearray (str)); [' Hello ']
var num = 123;
Console.log ($.makearray (num)); [123]
Examples of use (internal use):
var num = 123;
Console.log ($.makearray (num, {length:0})); {0:123,length:1}
varCore_push =Array.prototype.push, ..... jquery.extend ( ...) ....... .......--------------//results is for internal usage onlyMakearray:function(arr, results) {vartype, ret= Results | | []; if(Arr! =NULL ) { //the window, strings (and functions) also has ' length ' //tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930Type =Jquery.type (arr); if(Arr.length = =NULL|| Type = = = "string" | | Type = = = "Function" | | Type = = = "RegExp" | |Jquery.iswindow (arr)) {Core_push.call (ret, arr); } Else{jquery.merge (ret, arr); } } returnret; }, Merge:function(first, second) {varL =Second.length, I=First.length, J= 0; if(typeofL = = = "Number" ) { for(; J < L; J + +) {first[i++ ] =second[J]; } } Else { while(Second[j]!==undefined) {first[I+ +] = second[J + + ]; }} first.length=i; returnFirst ; }, ...............});
jquery Tool Method Makearray/merge