数组去重最好的写法。通俗易懂
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload=function(){
Array.prototype.unique3 = 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;
}
var arr = [112,112,34,'你好',112,112,34,'你好','str','str1'];
alert(arr.unique3());
};
</script>
</head>
<body>
</body>
</html>
学会忘记是生活的技术,学会微笑是生活的艺术