当前位置:网站首页>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 )
边栏推荐
- sql语句模糊查询遇到的问题
- 1111 online map (30 points)
- 并发操作-内存交互操作
- Silent authorization login and registration of wechat applet
- MPM model and ab pressure test
- On typescript and grammar
- Shuttle + alluxio accelerated memory shuffle take-off
- "Hands on deep learning" pytorch edition Chapter II exercise
- Market status and development prospect prediction of the global forward fluorescent microscope industry in 2022
- JQ style, element operation, effect, filtering method and transformation, event object
猜你喜欢

Flutter monitors volume to realize waveform visualization of audio

Kept hot standby and haproxy

Three representations of signed numbers: original code, inverse code and complement code

Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly

Celebrate the new year together

Actual combat 8051 drives 8-bit nixie tube

Shuttle + alluxio accelerated memory shuffle take-off

Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution
![[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)](/img/af/8dfa783c87363a9d75c52e7680d508.jpg)
[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)

Basic use of Metasploit penetration testing framework
随机推荐
Basic use of Metasploit penetration testing framework
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
sql语句模糊查询遇到的问题
Messy change of mouse style in win system
Market status and development prospect forecast of global heat curing adhesive industry in 2022
1107 social clusters (30 points)
I stepped on a foundation pit today
Keepalived热备与HAProxy
Market status and development prospect prediction of global fermentation acid industry in 2022
Gbase8s unique index and non unique index
Market status and development prospect prediction of global fermented plant protein industry in 2022
1115 counting nodes in a BST (30 points)
Oracle SQL table data loss
论文阅读_清华ERNIE
移动端——uniapp开发记录(公共请求request封装)
Shell script -- condition judgment
112 stucked keyboard (20 points)
1086 tree traversals again (25 points)
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
Problems encountered in fuzzy query of SQL statements