JScript Array对象的几个原型方法

来自:http://www.360doc.com/content/070131/16/10754_351369.html Array.prototype.inArray = function (value) { for (var i = 0; i < this.length; i++) { if (this[i] === value) { return true; } } return false; }; Array.prototype.max = function(){ for (var i = 1, max = this[0]; i < this.length; i++){ if (max < this[i]) { max = this[i]; } return max; }; Array.prototype.min = function(){ for (var i = 1, min = this[0]; i < this.length; i++){ if (min > this[i]) { min = this[i]; } return min; }; Array.prototype.indexOf = function(p_var) { for (var i=0; i-1) { this.splice(i,1); } return (i>-1); } Array.prototype.clear = function() { var iLength = this.length; for (var i=0; i < iLength; i++) { this.shift(); } } Array.prototype.addArray = function(p_a) { if (p_a) { for (var i=0; i < p_a.length; i++) { this.push(p_a[i]); } } } Array.prototype.Unique = function() { var a = {}; for(var i=0; i= 0; i--) { if (this[i] === obj) { return i; } } return -1; }; Array.prototype.insertAt = function(o, i) { this.splice(i, 0, o); }; Array.prototype.insertBefore = function(o, o2) { var i = this.indexOf(o2); if (i == -1) { this.push(o); } else { this.splice(i, 0, o); } }; Array.prototype.remove = function(o) { var i = this.indexOf(o); if (i != -1) { this.splice(i, 1); } }; Array.prototype.mm=function() { var a={}, m=0, n=""; for(var i=0; i
posted @ 2009-11-30 22:58  s80895304  阅读(151)  评论(0编辑  收藏  举报