<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
//选择N个数组中数值重复的个数等于N个数组 没有数组中都有的数值
function retainAll(){
var arrayLen = arguments.length;
var bucket = {};
for(var i = 0; i < arrayLen; i++){
var arr = arguments[i];
for(var j = 0, length = arr.length; j < length; j++){
bucket[arr[j]] = (bucket[arr[j]] || 0) + 1;
}
}
var result = [];
for(var key in bucket){
if(bucket[key] == arrayLen){
result.push(key);
}
}
return result;
}
var s = new Array();
s.push("1");
s.push("21");
var s1 = new Array();
s1.push("2");
s1.push("21");
alert(retainAll(s,s1));
</script>
</HEAD>
<BODY>
</BODY>
</HTML>