TNT blog  
          日歷
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345
          統計
          • 隨筆 - 5
          • 文章 - 40
          • 評論 - 7
          • 引用 - 0

          導航

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          home

          搜索

          •  

          最新隨筆

          最新評論

          閱讀排行榜

           
           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<this.length; i++)    
           {    
           
          if (this[i] == p_var)    
           {    
           
          return(i);    
           }    
           }    
           
          return(-1);    
           }    
             
           Array.prototype.exists 
          = function(p_var) {return(this.indexOf(p_var) != -1);}    
             
           Array.prototype.queue 
          = function(p_var) {this.push(p_var)}    
             
           Array.prototype.dequeue 
          = function() {return(this.shift());}    
             
           Array.prototype.removeAt 
          = function(p_iIndex) {return this.splice(p_iIndex, 1);}    
             
           Array.prototype.remove 
          = function(o)    
           {    
           
          var i = this.indexOf(o);    
           
          if (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<this.length; i++)    
           {    
           
          if(typeof a[this[i]] == "undefined")    
           a[
          this[i]] = 1;    
           }    
           
          this.length = 0;    
           
          for(var i in a)    
           
          this[this.length] = i;    
           
          return this;    
           };    
             
           Array.prototype.indexOf 
          = function(obj, fromIndex)    
           {    
           
          if (fromIndex == null)    
           {    
           fromIndex 
          = 0;    
           }    
           
          else if (fromIndex < 0)    
           {    
           fromIndex 
          = Math.max(0this.length + fromIndex);    
           }    
             
           
          for (var i = fromIndex; i < this.length; i++)    
           {    
           
          if (this[i] === obj)    
           {    
           
          return i;    
           }    
           }    
             
           
          return-1;    
           };    
             
           Array.prototype.lastIndexOf 
          = function(obj, fromIndex)    
           {    
           
          if (fromIndex == null)    
           {    
           fromIndex 
          = this.length - 1;    
           }    
           
          else if (fromIndex < 0)    
           {    
           fromIndex
          =Math.max(0this.length+fromIndex);    
           }    
             
           
          for (var i = fromIndex; 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<this.length; i++)    
           a[
          this[i]]?++a[this[i]]:a[this[i]]=1;    
           
          for(i in a){m=Math.max(m, a[i]); if(m==a[i]) n=i;}    
           
          return {"variable": n, "times": m}; 
          posted on 2007-09-14 11:35 TNT 閱讀(180) 評論(0)  編輯  收藏 所屬分類: JAVASCRIPT
           
          Copyright © TNT Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 武强县| 奉贤区| 固镇县| 黄浦区| 九龙城区| 罗江县| 新密市| 舞阳县| 佛教| 赤水市| 呈贡县| 资阳市| 榆中县| 阜宁县| 民县| 临高县| 临桂县| 贵溪市| 双城市| 榆社县| 镇巴县| 随州市| 沂南县| 安平县| 贵港市| 泰州市| 深州市| 西乌| 乐平市| 安康市| 门头沟区| 武定县| 出国| 慈溪市| 北碚区| 石屏县| 临夏市| 静宁县| 涿州市| 正定县| 屏东县|