至今而后 发表于 2013-1-29 08:56:56

js 去除数据重复数据

如题:
-------------
       Array.prototype.distinct = function() {      var ret = [];      for (var i = 0; i < this.length; i++) {         for (var j = i+1; j < this.length;) {             if (this.id === this.id) {               ret.push(this.splice(j, 1));             } else {               j++;             }         }      }      return ret;}
说明:此实例数组类型为
var values =new Object();
values.id= getValues.id;
values.text= getValues.text;
values.checked="1";

所以:判断条件为if (this.id === this.id)
如果数据类型为
var s = ;
则,修改为
if (this === this)
即可!
页: [1]
查看完整版本: js 去除数据重复数据