Posted in Javascript onDecember 19, 2013
function unique(data){ data = data || []; var a = {}; for (var i=0; i<data.length; i++) { var v = data[i]; if (typeof(a[v]) == 'undefined'){ a[v] = 1; } }; data.length=0; for (var i in a){ data[data.length] = i; } return data; } function test(){ var arr = [9,1,3,8,7,7,6,6,5,7,8,8,7,4,3,1]; var arr1 = unique(arr); alert(arr1.join(",")); } test();
js 高效去除数组重复元素示例代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@