Returns the subscript of an object in an array:
_arr represents an array of arrays that contains many objects such as:
_obj represents an Array object
function GetIndex (_arr,_obj) { var len = _arr.length; for (var i = 0; i < len; i++) { if(_arr[i] = = _obj ) {return parseint (i);} } return -1; };
Delete an object in an array: Returns the remaining array after deletion
/*delete an object in an array _arr: Array _obj: object to be deleted*/functionremoveaaary (_arr, _obj) {varLength =_arr.length; for(vari = 0; i < length; i++) { if(_arr[i] = =_obj) { if(i = = 0) {_arr.shift ();//Delete and return the first element of the array return_arr; } Else if(i = = Length-1) {_arr.pop (); //Delete and return the last element of the array return_arr; } Else{_arr.splice (i,1);//Delete the element labeled I return_arr; } } }}
JavaScript deletes the object specified in an array