如何在Javascript中比较数组和数据库字段值中的不相等值?

问题描述

我有这个变量从数据库获取特定的循环值:

var _ID;

for(var x = 0;x<id.length;x++){
    _ID = id[x];
}

现在,我已经设置了数组:

var _comID =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26];

然后我将此值与数据库中第一个循环中的 _ID 进行比较(完整代码如下): 我有这个变量在循环中从数据库获取特定值:

代码

var _ID;
var _comID =[1,26];


for(var x = 0;x<id.length;x++){
    _ID = id[x];//just to show
     for (z=0;z<_comID.length;z++){
        
        if(_comID[z] == id[x] ){
           console.log(_comID[z]); * //this print the equal value,how ever if not equal can't*
        }
        else{
            console.log(_comID[z]); *// this print all the value from 1 - 26. Please note that the value from  id[x] or _ID are random from 1 - 26 and sometimes its give only 18 to 23 numbers*
          }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)