当前位置:网站首页>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
边栏推荐
- 透过华为军团看科技之变(六):智慧公路
- 网易游戏,激进出海
- Lake shore optimag superconducting magnet system om series
- MySQL常用图形管理工具 | 黑马程序员
- 学习笔记-JDBC连接数据库操作的步骤
- Docker deploy mysql8.0
- Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit
- Viewing the whole ecology of Tiktok from a macro perspective
- The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
- 数据库基础:select基本查询语句
猜你喜欢

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

bean的生命周期核心步骤总结

Lake Shore 连续流动低温恒温器传输线

Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性

数商云:从规划到落地,五矿集团如何快速构建数字化发展新格局?

Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration

The market value evaporated by 74billion yuan, and the big man turned and entered the prefabricated vegetables

PMP是被取消了吗??

nacos配置文件发布失败,请检查参数是否正确的解决方案

MySQL常用图形管理工具 | 黑马程序员
随机推荐
M91 fast hall measuring instrument - better measurement in a shorter time
Learn MySQL from scratch - database and data table operations
Netease games, radical going to sea
Summary of the core steps in the life cycle of beans
Cdga | if you are engaged in the communication industry, you should get a data management certificate
Shell array
Usage and underlying implementation principle of PriorityQueue
Huawei cloud experts explain the new features of gaussdb (for MySQL)
Appgallery connect scenario development practice - image storage and sharing
寶,運維100+服務器很頭疼怎麼辦?用行雲管家!
transform + asm资料
Improve yolov5 with gsconv+slim neck to maximize performance!
Lake Shore 连续流动低温恒温器传输线
精益思想:来源,支柱,落地。看了这篇文章就懂了
Graduation summary
机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
PMP是被取消了吗??
Lake Shore - crx-em-hf low temperature probe station
实例讲解将Graph Explorer搬上JupyterLab
2020, the regular expression for mobile phone verification of the latest mobile phone number is continuously updated