//js代码如下:
1 function fnTogether(arr1,arr2){
2 var newArr = [];
3 for (var i = 0; i < arr1.length; i++) {
4 for(var j = 0; j < arr2.length; j++){
5 if(arr1[i] == arr2[j]){
6 if(newArr.indexOf(arr1[i]) == -1){
7 newArr.push(arr1[i]);
8 }
9 }
10 }
11 }
12 return newArr;
13 }
14 alert(fnTogether(arr1,arr2));