当前位置:网站首页>The difference between indexof and includes
The difference between indexof and includes
2022-07-01 19:20:00 【Lantau-·】
Array indexof Method
Determine whether a string contains substrings ( If it is included, the position of the string will be returned , Does not include return -1)
grammar :indexof(searchElement,fromIndex)
fromIndex( Optional . Start at this index to find searchElmentui)
let str = 'orange';
str.indexOf('o'); //0
str.indexOf('n'); //3
str.indexOf('c'); //-1
Array includes Method
Determine whether an array contains a specified value ( Include return true, Does not include return false)
grammar :includes(searchElement,fromIndex)
fromIndex( Optional . Start at this index to find searchElmentui)
var arr = [10,20,30,40,50];
arr.includes(10); //true
arr.includes(10,1); //false
indexof and includes The difference between
Different return values :
includes(): return Boolean type
indexof(): Back to a Integers Type value of , Indicates the index of the first occurrence of the current value in the array
NaN and undefined To deal with :
indexoOf() : You can't Match to in array NaN, I can't recognize undefined( Direct to ignore )
includes() : can Match to in array NaN, Can also recognize sparse arrays undefined
边栏推荐
- Viewing the whole ecology of Tiktok from a macro perspective
- 1. "Create your own NFT collections and publish a Web3 application to show them." what is NFT
- Excel之VBA简单宏编程
- C-end dream is difficult to achieve. What does iFLYTEK rely on to support the goal of 1billion users?
- How to realize the applet in its own app to realize continuous live broadcast
- Huawei game failed to initialize init with error code 907135000
- 机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
- Huawei cloud experts explain the new features of gaussdb (for MySQL)
- lefse分析
- Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒
猜你喜欢

Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase

【pytorch记录】自动混合精度训练 torch.cuda.amp

【直播预约】数据库OBCP认证全面升级公开课

Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit

AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award

案例分享:QinQ基本组网配置

Lake Shore低温恒温器的氦气传输线

Prices of Apple products rose across the board in Japan, with iphone13 up 19%

Create your own NFT collections and publish a Web3 application to show them (Introduction)

PMP是被取消了吗??
随机推荐
lefse分析
Excel之VBA简单宏编程
1. "Create your own NFT collections and publish a Web3 application to show them." what is NFT
Lumiprobe cell imaging study PKH26 cell membrane labeling kit
2020, the regular expression for mobile phone verification of the latest mobile phone number is continuously updated
[quick application] win7 system cannot run and debug projects using Huawei ide
Docker deploy mysql8.0
VBA simple macro programming of Excel
Dlib+Opencv库实现疲劳检测
The former 4A executives engaged in agent operation and won an IPO
精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
JS find the next adjacent element of the number in the array
Lake Shore - crx-em-hf low temperature probe station
Lumiprobe 亚磷酰胺丨六甘醇亚磷酰胺说明书
6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单
Database foundation: select basic query statement
AI training speed breaks Moore's law; Song shuran's team won the RSS 2022 Best Paper Award
MySQL common graphics management tools | dark horse programmers
[live broadcast appointment] database obcp certification comprehensive upgrade open class
Lumiprobe 细胞成像研究丨PKH26细胞膜标记试剂盒