Makearray:function (array, results) {//Convert an array-like object into a true JavaScript array. Results is an optional parameter
var ret = Results | | [];//results as an array that holds arry, set to an empty array if not defined
if (array!= null) {{//window,string,function,array of type. length is not undefined; (document.getElementById IE is undefined, Jquery.type (document.getElementById) is object, so a method like this is more special in IE, which can be used in jquery.
var type = Jquery.type (array);
if (Array.Length = null | | type = = "string" | | | = = = = "Function" | | type = = "RegExp" | | Jquery.iswindow (array))
Push.call (ret, array);//Incoming object is not an array, push joins the RET array
} else {
Jquery.merge (ret, array);//Incoming object is an array or similar array, directly merged into a RET array
}
}
return ret;
},
Inarray:function (Elem, array) {///search the specified value in the array and return its index (1 if not found).
if (indexOf) {//ecma-262 Standard browsers are supported, IE series to IE9 to support Array.prototype.indexOf,
return Indexof.call (array, elem);
}
for (var i = 0, length = Array.Length i < length; i++) {//IE9 The following version, by looping the array to determine
if (array[i] = = Elem) {
return i;
}
}
return-1;
},
Merge:function (A, second) {//merge array
var i = first.length,
j = 0;
if (typeof second.length = = "Number") {//Simple to detect if the object has a length property, there are loops added to the action array after
for (var L = second.length J < L; j + +) {//string,array type
first[i++] = second[J];
}
} else {
while (Second[j]!== undefined) {
first[i++] = second[j + +];
}
}
First.length = i;
return A;
},
Grep:function (Elems, callback, INV) {//Find the array element that satisfies the filter function. The original array is unaffected.
var ret = [], retVal;
INV =!! The inv;//is converted to a Boolean value type if the INV is not explicitly specified or specified as False,inv=false;
for (var i = 0, length = elems.length i < length; i++) {
RetVal =!! Callback (elems[i], i);//Convert to Boolean value type
if (Inv!== retVal) {//callback Returns the result if it is the opposite of inv, that is, preserve
Ret.push (elems[i]);
}
}
return ret;
},
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.