当前位置:网站首页>JS indexof() always returns -1

JS indexof() always returns -1

2022-06-25 11:42:00 Duxiaolie

Problem description :

Use indexOf() Determine whether a value is in Js in . When you try , This number is just js Array , But always return -1.


Cause analysis :

Consider whether the type is correct .


Solution :

Number( Numeric variable );
for example :
var idCar = ‘3’;
var value = indexOf(idCar);
console.log(value);
if(value != -1){
alert(“ The ID card already exists ”);
}

原网站

版权声明
本文为[Duxiaolie]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200536132478.html