当前位置:网站首页>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 - | – |
边栏推荐
- JS变量类型以及常用类型转换
- STM32型号与Contex m对应关系
- ES6语法总结--下篇(进阶篇 ES6~ES11)
- Arduino uno R3 register writing method (1) -- pin level state change
- Machine learning -- decision tree (sklearn)
- 列表的使用
- Arm pc=pc+8 is the most understandable explanation
- vim命令行笔记
- Raspberry pie tap switch button to use
- Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries
猜你喜欢
Small L's test paper
A possible cause and solution of "stuck" main thread of RT thread
Priority inversion and deadlock
Vert. x: A simple login access demo (simple use of router)
MP3mini播放模块arduino<DFRobotDFPlayerMini.h>函数详解
JS变量类型以及常用类型转换
Arm pc=pc+8 is the most understandable explanation
Principle and implementation of MySQL master-slave replication
Cannot change version of project facet Dynamic Web Module to 2.3.
Basic use of pytest
随机推荐
列表的使用
Apprentissage automatique - - régression linéaire (sklearn)
共用体(union)详解【C语言】
Principle and implementation of MySQL master-slave replication
Some concepts often asked in database interview
AMBA、AHB、APB、AXI的理解
Mp3mini playback module Arduino < dfrobotdfplayermini H> function explanation
Several declarations about pointers [C language]
Machine learning -- linear regression (sklearn)
arduino获取随机数
.elf .map .list .hex文件
MySQL数据库面试题
C language, log print file name, function name, line number, date and time
inline详细讲解【C语言】
Matlab learning and actual combat notes
Fashion Gen: the general fashion dataset and challenge paper interpretation & dataset introduction
Unit test - unittest framework
Analysis of charging architecture of glory magic 3pro
Pytoch temperature prediction
Come and walk into the JVM