当前位置:网站首页>Common methods of JS array
Common methods of JS array
2022-07-03 05:04:00 【The wind blows and birds fly in the crotch】
reverse Flip
sort Sort
push Add... From the back
unshift Add... From the front
pop Delete... From the back
shift Remove... From the front
indexOf From front to back string index
lastIndexOf String index from back to front
join,toString Convert to string type , It is recommended to use join
concat Become
slice Intercept ( A large array is only a part of a fragment )
splice Delete
How arrays are created ( Get to know )
I can only write it literally
Type of data
Simple data type :number,string,boolean,null,undefined (null It's printed out object)
Composite data type , Complex data type :array,object ( Array is also a special kind of object )
We can't get through typeof To detect whether a data is an array , Use other ways to detect :
1. data instanceof Array true The description is an array
2. Array.isArray( data )true The description is an array
Array add elements
1. push PUSH Add at the back ( The most used )
2. unshift Add... To the front
3. pop Remove the last one
4. shift Remove the first one
sort Method in use , The default is to convert all data into strings , Then press ascii Compare in order
Primacy and primacy comparison
reverse() Flip array
sort(function(a,b){return a - b;})
If you ask bubble sort , --> double for Cyclic writing
Find whether the element is in the array , Position in array ( The first index value ), If not, the return value is -1
indexOf Look back before ( Commonly used )
lastIndexOf Look backwards
indexOf Has two functions
1. You can detect the position of elements in the array
2. You can detect whether there is this element in the array ( duplicate removal )
边栏推荐
- Market status and development prospect prediction of the global fire extinguisher industry in 2022
- 1087 all roads lead to Rome (30 points)
- cookie session jwt
- SSM framework integration
- Uipath practice (08) - selector
- My first Smartphone
- [batch dos-cmd command - summary and summary] - CMD window setting and operation command - close CMD window and exit CMD environment (exit, exit /b, goto: EOF)
- The 19th Zhejiang I. barbecue
- Flutter monitors volume to realize waveform visualization of audio
- Cross platform plug-in flutter for displaying local notifications_ local_ notifications
猜你喜欢
Shuttle + alluxio accelerated memory shuffle take-off
Basic use of Metasploit penetration testing framework
JDBC database operation
[research materials] 2022q1 game preferred casual game distribution circular - Download attached
SSM framework integration
How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in
How to connect the network: Chapter 1 CSDN creation punch in
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Analysis of proxy usage of ES6 new feature
论文阅读_清华ERNIE
随机推荐
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
1094 the largest generation (25 points)
Thesis reading_ Chinese NLP_ ELECTRA
1119 pre- and post order traversals (30 points)
Keepalived热备与HAProxy
Caijing 365 stock internal reference: what's the mystery behind the good father-in-law paying back 50 million?
1106 lowest price in supply chain (25 points)
Market status and development prospect prediction of global colorimetric cup cover industry in 2022
How to connect the network: Chapter 1 CSDN creation punch in
Notes | numpy-11 Array operation
Wechat applet waterfall flow and pull up to the bottom
Current market situation and development prospect forecast of the global fire boots industry in 2022
Handler understands the record
Uipath practice (08) - selector
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
Market status and development prospect prediction of global SoC Test Platform Industry in 2022
M1 Pro install redis