麻雀的确可爱,它的脑袋很小,只有栗子那么大,眼晴虽小却非常有神,它的身体小巧成蛋状流线型,放在手上只占手掌的一半。它浑身长着灰褐色羽毛,和树皮色相似,是一种保护色,它颈部和腹部的毛发白,显得很匀称,它的尾巴像半张开的小扇子。它飞得很快,也很有趣,那么一窜窜的。
在线文本去重复工具
第一种方法:
<textarea id="list" class="toolarea">
www.haodaima.com
www.baidu.com
www.haodaima.com
shouce.haodaima.com
www.haodaima.com
tools.haodaima.com
www.baidu.com
shouce.haodaima.com
tools.haodaima.com
www.haodaima.com</textarea>
<input type="button" onclick="process()" value="去重处理" class="bt-green">
<script type="text/javascript">
function unique(ary) {
var i = 0,
gid='_'+(+new Date)+Math.random(),
objs = [],
hash = {
'string': {},
'boolean': {},
'number': {}
}, p, l = ary.length,
ret = [];
for (; i < l; i++) {
p = ary[i];
if (p == null) continue;
tp = typeof p;
if (tp in hash) {
if (!(p in hash[tp])) {
hash[tp][p] = 1;
ret.push(p);
}
} else {
if (p[gid]) continue;
p[gid]=1;
objs.push(p);
ret.push(p);
}
}
for(i=0,l=objs.length;i<l;i++) {
p=objs[i];
p[gid]=undefined;
delete p[gid];
}
return ret;
}
function process(){
list = document.getElementById('list');
arr = list.value.split('\n');
arr = unique(arr);
list.value = "";
for(key in arr){
list.value += arr[key] + '\n';
}
alert("处理完成!");
}
</script>
第二种方法
function sx(){
var rntArray=[],temp,hasValue;
var array=document.getElementById("neirong").value.split("\n");
for(var i in array){
temp=array[i];
hasValue=false;
for(var j in rntArray){
if(temp===rntArray[j]){
hasValue=true;
break;
}
}
if(hasValue===false){
rntArray.push(temp);
}
}
document.getElementById("neirong1").value=rntArray.join("\n");
}
本文javascript 数组去重复(在线去重工具)到此结束。墙高万丈,挡的只是不来的人,要来,千军万马也是挡不住的。小编再次感谢大家对我们的支持!