var a=[1,2,3,3,3,3,3,2,2,];
Array.prototype.unique1 = function()
{
var n = []; //一个新的临时数组
for(var i = 0; i < this.length; i++) //遍历当前数组
{
if (n.indexOf(this[i]) == -1) n.push(this[i]);
//--------------------- 这句话怎么理解-------------------------------------
}
return n;
}
console.log(a.unique1());来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1427/viewspace-3145966/ ,如需转载,请注明出处,否则将追究法律责任。