Array.prototype.del = function () { var a = {}, c = [], l = this.length; for (var i = 0; i < l; i++) { var b = this[i]; var d = (typeof b) + b; if (a[d] === undefined) { c.push(b); a[d] = 1; } } return c; }
调用如下:
var Ary = ["生活服务类", "健康保健类", "便民服务", "社区服务", "生活服务类", "健康保健类", "便民服务", "社区服务"] Ary = Ary.del(); console.log(Ary);
@