js 数组去重

           //独立方法
         Array.prototype.unique = function() {
		var res = [];
		var json = {};
		for (var i = 0; i < this.length; i++) {
			if (!json[this[i]]) {
				res.push(this[i]);
				json[this[i]] = 1;
			}
		}
		return res;
	}    
    
            //调用
            数组.unique();

  

猜你喜欢

转载自www.cnblogs.com/cxw-cm/p/9212284.html