Nodejs Utililty Methods Array Delete

List of utility methods to do Array Delete

Description

The list of methods to do Array Delete are organized into topic(s).

Method

del(index)
Array.prototype.del = function(index){
    if(isNaN(index) || index > this.length || index < 0){
        return false;
    this.splice(index,1);
del(n)
Array.prototype.del=function(n) {
  if(n<0){
    return this;
  }else{
    return this.slice(0,n).concat(this.slice(n+1,this.length));
deleteRepeat()
Array.prototype.deleteRepeat = function(){
  var arr = this, 
    result=[], 
    flag; 
  for(var i=0;i<arr.length;i++){
    flag=true;
    for(var j=0;j<result.length;j++){
      if(result[j]===arr[i]){
        flag=false;
...
deleteSame()
function JsonSort(json,key){
    for(j=1;j < json.length;j++){
        var temp = json[j],
            val  = temp[key],
            i    = j-1;
        while(i >=0 && json[i][key]>val){
            json[i+1] = json[i];
            i = i-1;
        json[i+1] = temp;
    return json;
Array.prototype.deleteSame = function(){
  var res = [this[0]];
  for(var i = 1; i < this.length; i++){
    var repeat = false;
    for(var j = 0; j < res.length; j++){
      if(this[i] == res[j]){
        repeat = true;
        break;
    if(!repeat){
      res.push(this[i]);
  return res;
trim(deleteValue)
Array.prototype.trim = function(deleteValue) {
  var i;
  for (i = 0; i < this.length && this[i] == deleteValue;) {
    this.splice(i, 1);
  for (i = this.length-1; i >= 0 && this[i] == deleteValue; --i) {
    this.splice(i, 1);
  return this;
...