Remove spaces on both sides of the string String.prototype.trim = function () { var re =/(^\s*) | (
\s*) $/g;
return This.replace (Re, "");} Deletes an element in an array Array.prototype.remove = function (i) { var o = this[i]; for (var j = i; j < th Is.length-1; J + +) { THIS[J] = this[j + 1];//starting from the first element, to the penultimate element, replacing the previous element with the following elements }
--this.length; return o; //Determine if an array has the same element Array.prototype.search = function (o) { for (var i = 0; i < this.length i + +) {& nbsp
if (this[i] = O) { return i; }
} return-1;
//Below is the test var str = "This is test string ";
Console.log (str);
Console.log (Str.trim ());
Console.log (str);
var arr = [1, 2, 3, 4];
Console.log (arr.length);
Console.log (Arr.remove (2));
Console.log (arr);
var arr = [1, 2, 3, 4]; Console.log (arr.searCH (5));
Console.log (Arr.search (3));
Reference: http://security.ctocio.com.cn/tips/337/7716837_3.shtml