1. Creating an array
var array = new Array ();var array = new Array (size);//Specifies the length of the arrayvar array = new Array (item1,item2......itemn);//Create an array and assign a value 2, Value, assignmentvar item = array[index];//Gets the value of the specified elementArray[index] = value;//assigns a value to the specified element 3. Add new elementsArray.push (ITEM1,ITEM2......ITEMN);//Add one or more elements to the array, returning the length of the new arrayArray.unshift (ITEM1,ITEM2......ITEMN);//Add one or more elements to the beginning of the array, the original element position is automatically moved back, return the length of the new arrayArray.splice (START,DELCOUNT,ITEM1,ITEM2......ITEMN);//Remove delcount elements from start position and insert one or more new elements from start position 4. Deleting elementsArray.pop ();//delete the last element and return the elementarray.shift ();//delete the first element, the position of the array element is automatically moved forward, and the deleted element is returnedArray.splice (Start,delcount);//Remove delcount elements from start position backward 5. Merging and intercepting arraysArray.slice (start,end);//Returns the part of the array as an array, noting that the end corresponding element is not included, and if the end is omitted, all elements after start are copiedArray.concat (array1,array2);//concatenation of multiple arrays into an array 6. Sorting of Arraysarray.reverse ();//array inversionArray.Sort ();//array sort, return array address 7. Array to stringArray.join (separator);//Connect the array reason with separator 8, the JQ judge whether the value exists in the array
var Mobilearr = ["13", "15", "18"];
var mob = mobile.substr (0, 2);
var rs = $.inarray (mob, Mobilearr);
Return RS;
Does not exist return-1 exists return index
the list is so all there is no way to delete an array element from the subscript! So I looked up some information and found a solution. Deleting an array element requires extending the array prototype prototype.The subscript of the general array is numeric, but there are also the subscript of the character typenumeric processing, the first to write out the following code, is the expansion of the arrayArray.prototype.del = function (dx){ if (IsNaN (dx) | | Dx>this.length) {return false;}This.splice (dx,1);} second, the numerical value of the direct transfer of numerical parameters can be. For example var arr = ["AA", "BB"];arr.del (0);Let's talk about the subscript of the character type.var arr = [].arr["AA"] = 1; Unknown Source: Network
The use of the JS array and the array to remove the elements based on the subscript (numeric or character)