当前位置:网站首页>JS judge whether a number is in the set

JS judge whether a number is in the set

2022-06-25 11:42:00 Duxiaolie

demand : Judge IdCar Uniqueness .
describe : Through investigation API Get all the IdCar, Use HashSet For storage . Return this collection to the front end , Form a double check between the front end and the back end .

There's a problem : Use... On the front end indexOf() When checking , This value is clearly in the set , But always return to **-1** .
reason : It's the wrong type . resolvent : Use the front-end type conversion method Number().

js:
Determine whether a value is in an array ( aggregate ) in .
indexOf()、includes()
https://zhidao.baidu.com/question/425115453.html
Application scenarios : The front-end check 、 Judgment processing logic .
“ Check one id Whether it has existed , Background check 、 The front end is also verified .
Concrete realization : Request domain -> Front desk inspection

原网站

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