当前位置:网站首页>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 )
边栏推荐
- Source insight garbled code solution
- The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
- Flutter monitors volume to realize waveform visualization of audio
- Shallow and first code
- Market status and development prospect prediction of global colorimetric cup cover industry in 2022
- Blog building tool recommendation (text book delivery)
- Mobile terminal - uniapp development record (public request encapsulation)
- 1111 online map (30 points)
- Distinguish between releases and snapshots in nexus private library
- Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
猜你喜欢

2022-02-12 daily clock in: problem fine brush

【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)

Interface frequency limit access

Actual combat 8051 drives 8-bit nixie tube

"Niuke brush Verilog" part II Verilog advanced challenge

RT thread flow notes I startup, schedule, thread

Handling record of electric skateboard detained by traffic police
![[tools run SQL blind note]](/img/c3/86db4568b221d2423914990a88eec2.png)
[tools run SQL blind note]

leetcode435. Non overlapping interval

First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
随机推荐
Handler understands the record
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)
Market status and development prospects of the global automatic tea picker industry in 2022
2022-02-11 daily clock in: problem fine brush
Esp32-c3 learning and testing WiFi (II. Wi Fi distribution - smart_config mode and BlueIf mode)
Dynamic programming - related concepts, (tower problem)
[SQL injection point] location and judgment of the injection point
Shuttle + Alluxio 加速内存Shuffle起飞
Market status and development prospect prediction of global neutral silicone sealant industry in 2022
I stepped on a foundation pit today
leetcode452. Detonate the balloon with the minimum number of arrows
Market status and development prospect prediction of the global fire alarm sensor industry in 2022
The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
"Pthread.h" not found problem encountered in compiling GCC
1086 tree traversals again (25 points)
Wechat applet distance and map
[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa
Shallow and first code
【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)