当前位置:网站首页>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 )
边栏推荐
- 1114 family property (25 points)
- JDBC database operation
- Shallow and first code
- 最大连续子段和(动态规划,递归,递推)
- Flutter monitors volume to realize waveform visualization of audio
- [tools run SQL blind note]
- The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
- Based on RFC 3986 (unified resource descriptor (URI): general syntax)
- [set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
- C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
猜你喜欢

Source insight garbled code solution

RT thread flow notes I startup, schedule, thread

On typescript and grammar

Uipath practice (08) - selector

LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)

Thesis reading_ ICD code_ MSMN

论文阅读_清华ERNIE

Do you know UVs in modeling?

Online VR model display - 3D visual display solution

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
随机推荐
论文阅读_ICD编码_MSMN
Learn to use the idea breakpoint debugging tool
Unity tool Luban learning notes 1
Wechat applet distance and map
Distinguish between releases and snapshots in nexus private library
Esp32-c3 learning and testing WiFi (II. Wi Fi distribution - smart_config mode and BlueIf mode)
1118 birds in forest (25 points)
The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
论文阅读_中文医疗模型_ eHealth
Thesis reading_ Chinese medical model_ eHealth
[backtrader source code analysis 4] use Python to rewrite the first function of backtrader: time2num, which improves the efficiency by 2.2 times
Review the configuration of vscode to develop golang
Career planning of counter attacking College Students
MediaTek 2023 IC written examination approved in advance (topic)
[research materials] 2022q1 game preferred casual game distribution circular - Download attached
Market status and development prospect prediction of global fermented plant protein industry in 2022
sql语句模糊查询遇到的问题
Caijing 365 stock internal reference: what's the mystery behind the good father-in-law paying back 50 million?
文献阅读_基于多模态数据语义融合的旅游在线评论有用性识别研究(中文文献)
My first Smartphone