当前位置:网站首页>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
边栏推荐
- Learn MySQL from scratch - database and data table operations
- ES6数组方法find()、findIndex()的总结「建议收藏」
- Go语言自学系列 | go语言数据类型
- Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
- Is PMP cancelled??
- 网易游戏,激进出海
- [AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?
- The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables
- docker 部署mysql8.0
- Golang error handling
猜你喜欢

Solution of intelligent supply chain management platform in aquatic industry: support the digitalization of enterprise supply chain and improve enterprise management efficiency

Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference

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

Getting started with kubernetes command (namespaces, pods)

水产行业智能供应链管理平台解决方案:支撑企业供应链数字化,提升企业管理效益

Improve yolov5 with gsconv+slim neck to maximize performance!

Learn MySQL from scratch - database and data table operations
![[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](/img/5c/b0030fd5fbc07eb94013f2699c2a04.png)
[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

Example explanation: move graph explorer to jupyterlab

M91 fast hall measuring instrument - better measurement in a shorter time
随机推荐
PMP是被取消了吗??
SuperOptiMag 超导磁体系统 — SOM、SOM2 系列
Three ways for redis to realize current limiting
Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
How to use the low code platform of the Internet of things for personal settings?
Dlib+Opencv库实现疲劳检测
Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?
ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
Lake Shore 连续流动低温恒温器传输线
【Go ~ 0到1 】 第四天 6月30 defer,结构体,方法
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
Once the SQL is optimized, the database query speed is increased by 60 times
M91快速霍尔测量仪—在更短的时间内进行更好的测量
Dom4J解析XML、Xpath检索XML
Supervarimag superconducting magnet system SVM series
华为游戏初始化init失败,返回错误码907135000
MySQL common graphics management tools | dark horse programmers
The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
云服务器ECS夏日省钱秘籍,这次@老用户快来领走
Lake Shore M91快速霍尔测量仪