当前位置:网站首页>Important methods of array and string
Important methods of array and string
2022-07-06 12:07:00 【KAMHUNCHAN】
Array | String |
---|---|
indexOf( Array elements , Specify where to start searching ) // Returns the first index number that satisfies the condition , If you can't find it, go back to -1 | str.indexOf(“ Search for characters ”, Start looking for the location ) // Return the first found subscript , Return if not found -1 |
lastIIndexOf( Array elements ) // Returns the last index number that meets the condition , If you can't find it, go back to -1 | – |
Convert to string arr.toString() ;arr.join("-") | Convert to array :str.split(’=’) |
slice(begin,end) // Intercept array intercept array subscript from begin To end The content of , It doesn't contain endbegin Out of array range , Will return an empty array | slice(begin,end);substring(begin,end) Negative values are not acceptable , these two items. end It's a subscript , Can't get ;substr(star,length)length It's a number |
splice(star,deleteCount,item1, item2, … Optional )-start Specify where to start the modification ( from 0 Count ). If the length of the array is exceeded , Then add content from the end of the array ; If it's negative , Represents the number of bits starting from the end of the array ( from -1 Count , It means -n It's the last n And is equivalent to array.length-n); If the absolute value of a negative number is greater than the length of the array , It means that the starting position is 0 position .deleteCount Optional integer , Represents the number of array elements to remove . If deleteCount Greater than start The total number of elements after , From start Later elements will be removed ( Hendy start position ). If deleteCount Was omitted , Or its value is greater than or equal to array.length - start( in other words , If it is greater than or equal to start The number of all elements after ), that start After that, all elements of the array will be deleted . If deleteCount yes 0 Or negative , The element is not removed . In this case , At least one new element should be added .item1, item2, … Optional elements to be added to the array , from start Position start . If you don't specify , be splice() Only array elements will be removed . The return value is an array of deleted elements . If only one element is deleted , Returns an array containing only one element . If the element is not deleted , Then return an empty array . This method will change the original array - | – |
边栏推荐
- Contiki source code + principle + function + programming + transplantation + drive + network (turn)
- Embedded startup process
- RT-Thread 线程的时间片轮询调度
- Fashion-Gen: The Generative Fashion Dataset and Challenge 论文解读&数据集介绍
- Arduino get random number
- 機器學習--線性回歸(sklearn)
- gcc 编译选项
- arduino获取随机数
- Detailed explanation of 5g working principle (explanation & illustration)
- Matlab learning and actual combat notes
猜你喜欢
电商数据分析--薪资预测(线性回归)
AMBA、AHB、APB、AXI的理解
Machine learning -- linear regression (sklearn)
Fashion-Gen: The Generative Fashion Dataset and Challenge 论文解读&数据集介绍
STM32 how to locate the code segment that causes hard fault
OPPO VOOC快充电路和协议
機器學習--線性回歸(sklearn)
几个关于指针的声明【C语言】
[template] KMP string matching
mysql实现读写分离
随机推荐
MySQL START SLAVE Syntax
高通&MTK&麒麟 手机平台USB3.0方案对比
I2C bus timing explanation
Variable star user module
Amba, ahb, APB, Axi Understanding
Those commonly used tool classes and methods in hutool
ESP学习问题记录
STM32型号与Contex m对应关系
Programmers can make mistakes. Basic pointers and arrays of C language
Distribute wxWidgets application
Kconfig Kbuild
XML文件详解:XML是什么、XML配置文件、XML数据文件、XML文件解析教程
Come and walk into the JVM
荣耀Magic 3Pro 充电架构分析
Internet protocol details
FTP文件上传文件实现,定时扫描文件夹上传指定格式文件文件到服务器,C语言实现FTP文件上传详解及代码案例实现
R & D thinking 01 ----- classic of embedded intelligent product development process
E-commerce data analysis -- User Behavior Analysis
Rough analysis of map file
map文件粗略分析