The example is as follows:
//Example
var test = new Array(1,5,3,4,2);
//Output 5
console.log(test.length);
// Delete the element with value 4
test = test.deleteValue(4);
//Output [1, 5, 3, 2]
console.log(test);
//Output 4
console.log(test.length);
/**
* Delete array elements by index
*
* @param int index element index
* @returns array
*/
Array.prototype.deleteIndex = function(index){
return this.slice(0, index).concat(this.slice(parseInt(index, 10) 1));
}
//Example
var test = new Array(1,5,3,4,2);
//Output 5
console.log(test.length);
// Delete the element with index 1
test = test.deleteIndex(1);
//Output [1, 3, 4, 2]
console.log(test);
//Output 4
console.log(test.length);