1 Array.prototype.contain = function(e){ 2 for(i=0;i<this.length;i++){ 3 if(this[i] == e) 4 return true; 5 } 6 return false; 7 }; 8 9 Array.prototype.indexOf = function(val) { 10 for (var i = 0; i < this.length; i++) { 11 if (this[i] == val) return i; 12 } 13 return -1; 14 }; 15 Array.prototype.remove = function(val) { 16 var index = this.indexOf(val); 17 if (index > -1) { 18 this.splice(index, 1); 19 } 20 }; 21 22 Array.prototype.distinct=function(){ 23 var a = {}, c = [], l = this.length; 24 for (var i = 0; i < l; i++) { 25 var b = this[i]; 26 var d = (typeof b) + b; 27 if (a[d] === undefined){ 28 c.push(b); 29 a[d] = 1; 30 } 31 } 32 return c; 33 };