http://www.nowamagic.net/librarys/veda/detail/1487
http://bbs.chinaunix.net/thread-3650610-1-1.html
http://www.phpernote.com/php-function/516.html
1例子
//去除数组的重复值,使用方式:arr.del()
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 arr = new Array();
arr = [1,2,3,4,3,4,5,9,7,5,6];
alert(arr.del());
结果:1,2,3,4,5,6,7,9
本文介绍了一种JavaScript中去除数组重复元素的方法,并提供了一个具体的实现示例。通过自定义Array.prototype.del方法,可以轻松地去除数组中的重复项。
520

被折叠的 条评论
为什么被折叠?



