当前位置:网站首页>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 ”);
}
边栏推荐
- Capacity expansion mechanism of Dict Of redis (rehash)
- Multiple clicks of the button result in results
- Comparator (for arrays.sort)
- 建造者模式
- Record the process of submitting code to openharmony once
- Shichuang energy rushes to the scientific innovation board: it plans to raise 1.1 billion yuan, with an annual revenue of 700million yuan and a 36% decrease in net profit
- 基於Minifilter框架的雙緩沖透明加解密驅動 課程論文+項目源碼
- Database Series: MySQL index optimization summary (comprehensive version)
- Evaluating the overall situation of each class in a university based on entropy weight method (formula explanation + simple tool introduction)
- 剑指 Offer II 091. 粉刷房子 : 状态机 DP 运用题
猜你喜欢
Database Series: MySQL index optimization summary (comprehensive version)
Golden sun education listed in the U.S.: a small cap medium cap stock with a market value of USD 360million
Niuke.com: Candy distribution
推荐一款M1电脑可用的虚拟机软件
Spark runs wordcount (case 2)
基于超算平台气象预警并行计算架构研究
Nacos installation and use
Double buffer transparent encryption and decryption driven course paper + project source code based on minifilter framework
为什么要分布式 id ?分布式 id 生成方案有哪些?
Idea local launch Flink task
随机推荐
時創能源沖刺科創板:擬募資11億 年營收7億淨利反降36%
Deeply understand Flink SQL execution process based on flink1.12
牛客网:分糖果问题
Thingpanel publie le client mobile IOT (Multi - images)
Hangzhou / Beijing neitui Ali Dharma academy recruits academic interns in visual generation (talent plan)
Keywords serializable serialization and deserialization
芯片的发展史和具体用途以及结构是什么样的
Convergence by probability
Spark Tuning common configuration parameters
兴业证券是国企吗?在兴业证券开户资金安全吗?
Leetcode 1249. Remove invalid brackets (awesome, finally made)
Detailed explanation of Spark's support source code for Yan priority
Comparison between relu and SIGMOD
Niuke: rotation array
基于超算平台气象预警并行计算架构研究
Openfeign uses
Wait (), notify (), notifyAll (), sleep (), condition, await (), signal()
Sword finger offer II 091 Painting house: application of state machine DP
Use of Presto visualization client-yanagishima20.0
Kingbasees plug-in DBMS of Jincang database_ UTILITY