js判断相等遇到奇怪的问题

问题:

tabledata[i].fund_type值是A的时候

if( tabledata[i].fund_type== "A") 用console.log打印出来是false

排除:

1、使用了typeof 类型都是字符串类型

2、这样tabledata[i].fund_type == tabledata[i].fund_type 打印出来是也是false

最后 直接转为String

tabledata[i].fund_type是A的时候

console.log(String(tabledata[i].fund_type) == "A") true

猜你喜欢

转载自blog.csdn.net/qq_39313596/article/details/106018236
今日推荐