nodejs的 new String
已知rwo4的记录中baitaiid是001
// row4为jhlist开始循环结果
for(var i=0;i<row4.length;i++)
{
var baiTaiId=new String(row4[i].BAITAI_ID);
switch (baiTaiId) {
case "001":
console.log("this is:"+baiTaiId);
break;
case "002":
console.log("this is:"+baiTaiId);
break;
case "003":
console.log("this is:"+baiTaiId);
break;
case "004":
console.log("this is:"+baiTaiId);
break;
case "005":
console.log("this is:"+baiTaiId);
break;
case "006":
console.log("this is:"+baiTaiId);
break;
default:
console.log("else");
break;
}
}
预想结果:this is:001;
实际结果:else;
为此我单独的看了一下 console.log(bataiid);
其显示结果确实是001.
好奇怪为什么回事
于是 我就改成这样了
new String(row4[i].BAITAI_ID).toString();
奇怪new String 了还要tostring
原来:
哪位大侠知道为什么这两种类型不一样。

浙公网安备 33010602011771号