日期:2014-05-16 浏览次数:20354 次
var getuserInfo = ["a","b","c"];
var userInfo = ["a","f","e","g"];
var index = 0;
for(var s in getuserInfo){
for(var x in userInfo){
if(getuserInfo[ 2 * s]!=userInfo[2 * x]){
userInfo[index++] = getuserInfo[2 * s];
userInfo[index++] = getuserInfo[2 * s + 1];
}
}
}
var getuserInfo = ["a","b","c"];
var userInfo = ["a","b","f","e","g"];
var flag ;
for(var i = 0 ; i < getuserInfo.length ; ){
flag = false;
for(var j = 0 ; j < userInfo.length ; ){
if(userInfo[j]==getuserInfo[i]){
userInfo.splice(j , 1);
getuserInfo.splice(i , 1);
flag = true;
}else{
++j;
}
}
if(!flag)
++i;
}
console.log(getuserInfo.concat(userInfo));
var getuserInfo = ["a","b","c",["e","f"]];
var userInfo = ["a","b","f","e","g"];
var testInfo = [];
var flag ;
for(var i = 0 ; i < getuserInfo.length ;i++ ){
for(var count =0;count<getuserInfo[i].length;count++)
{
testInfo[getuserInfo[i][count]]= getuserInfo[i][count];
}
}
for(var j =0 ;j<userInfo.length;j++)
{
if(testInfo[userInfo[j]])
{
testInfo[userInfo[j]] =null;
}
else
{
testInfo[userInfo[j]] = userInfo[j];
}
}
console.log(testInfo.join(","));
var getuserInfo = ["a","b","c",["e","f"]];
var userInfo = ["a","b","f","e","g"];
var testInfo = [];
for(var i = 0 ; i < getuserInfo.length ;i++ ){
for(var count =0;count<getuserInfo[i].length;count++)
{
testInfo[getuserInfo[i][count]]= getuserInfo[i][count];
}