当前位置:网站首页>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 - | – |
边栏推荐
- STM32 how to locate the code segment that causes hard fault
- Machine learning -- linear regression (sklearn)
- Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries
- FTP file upload file implementation, regularly scan folders to upload files in the specified format to the server, C language to realize FTP file upload details and code case implementation
- 分布式事务的实现方案
- Imgcat usage experience
- inline详细讲解【C语言】
- 电商数据分析--用户行为分析
- Détails du Protocole Internet
- GNN的第一个简单案例:Cora分类
猜你喜欢
Pytorch four commonly used optimizer tests
5G工作原理详解(解释&图解)
I2C bus timing explanation
Time slice polling scheduling of RT thread threads
uCOS-III 的特点、任务状态、启动
Implementation scheme of distributed transaction
Analysis of charging architecture of glory magic 3pro
电商数据分析--薪资预测(线性回归)
ARM PC=PC+8 最便于理解的阐述
ESP8266使用arduino连接阿里云物联网
随机推荐
List and set
The first simple case of GNN: Cora classification
imgcat使用心得
RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
Bubble sort [C language]
[esp32 learning-2] esp32 address mapping
STM32 如何定位导致发生 hard fault 的代码段
ESP learning problem record
Arduino get random number
Small L's test paper
MySQL realizes read-write separation
5G工作原理详解(解释&图解)
Matlab learning and actual combat notes
arduino获取数组的长度
ESP学习问题记录
Kconfig Kbuild
嵌入式启动流程
Dead loop in FreeRTOS task function
Dependency in dependencymanagement cannot be downloaded and red is reported
Oppo vooc fast charging circuit and protocol