当前位置:网站首页>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
边栏推荐
- 透过华为军团看科技之变(六):智慧公路
- Go language self-study series | go language data type
- js找出数字在数组中下一个相邻的元素
- [6.24-7.1] review of wonderful technical blog posts in the writing community
- Dom4J解析XML、Xpath检索XML
- Lake shore optimag superconducting magnet system om series
- Love business in Little Red Book
- Qfile read / write file operation in QT
- MySQL common graphics management tools | dark horse programmers
- 【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
猜你喜欢

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

实例讲解将Graph Explorer搬上JupyterLab

1. "Create your own NFT collections and publish a Web3 application to show them." what is NFT

透过华为军团看科技之变(六):智慧公路

Openai video pre training (VPT): action learning based on watching unmarked online videos

Lake shore M91 fast hall measuring instrument

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

如何使用物联网低代码平台进行个人设置?

linux下清理系统缓存并释放内存

Love business in Little Red Book
随机推荐
【pytorch记录】自动混合精度训练 torch.cuda.amp
Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
水产行业智能供应链管理平台解决方案:支撑企业供应链数字化,提升企业管理效益
云服务器ECS夏日省钱秘籍,这次@老用户快来领走
机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
How to operate technology related we media well?
Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
Create your own NFT collections and publish a Web3 application to show them (Introduction)
C-end dream is difficult to achieve. What does iFLYTEK rely on to support the goal of 1billion users?
Lean thinking: source, pillar, landing. I understand it after reading this article
Lumiprobe free radical analysis h2dcfda instructions
Lake Shore—CRX-EM-HF 型低温探针台
MySQL常用图形管理工具 | 黑马程序员
11. Users, groups, and permissions (1)
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
Prices of Apple products rose across the board in Japan, with iphone13 up 19%
How to realize the applet in its own app to realize continuous live broadcast
The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables
前4A高管搞代运营,拿下一个IPO
从零开始学 MySQL —数据库和数据表操作