当前位置:网站首页>JS foundation - array object
JS foundation - array object
2022-06-11 09:38:00 【Snatch bamboo shoots 123】
Catalog
Array object
Array creation
Create format
var Array name =new Array( Elements 1, Elements 2,... , Elements n);
var Array name =[ Elements 1, Elements 2,... , Elements n];
The assignment of an array
// Create an array
var arr=[];
// Assignment by subscript
arr[i]= value ;
Array length acquisition
// Create an array
var arr=[];
//length Is an attribute of an array object
arr.length; //0
Intercept array elements
arr.slice(start,end);
Similar to slicing , The interception range is [start,end), And the subscript of the first element of the array is 0
Array elements are added
Add a new element to the beginning of the array ( Change the original array )
arr.unshift( The new element 1, The new element 2,..., The new element n);
Add a new element to the end of the array ( Change the original array )
arr.push( The new element 1, The new element 2,..., The new element n);
// or
arr[n]= value 1;
arr[n+1]= value 2;
Delete array elements
Delete the last element of the array ( Change the original array )
arr.pop()
Delete and return the first element in the array ( Change the original array )
arr.shift();
The array is upside down
Reverse arrangement of all elements
arr.reverse();
Array sorting
Array name .sort();
Conversion of array and string
Join all the elements in the array into a string ( Do not change the original array )
Array name .join(" Connector ");
String name .split(" Connector ");
Example
arr=[" Qin Shi "," bright moon "," han "," when "," Turn off "]
str1=arr.join("**"); // Qin Shi ** bright moon ** han ** when ** Turn off
arr1=str1.split("**"); // [" Qin Shi "," bright moon "," han "," when "," Turn off "]
边栏推荐
- MySQL:Got a packet bigger than ‘max_ allowed_ packet‘ bytes
- Award winning survey streamnational sponsored 2022 Apache pulsar user questionnaire
- [scheme development] sphygmomanometer scheme pressure sensor sic160
- When the enterprise makes a decision, which part should lead the ERP project?
- Automation operation and maintenance articles collection
- 1400. 构造 K 个回文字符串
- js基础--Array对象
- Machine learning notes - the story of master kaggle Janio Martinez Bachmann
- Importance of implementation of clothing ERP in the project
- Openstack explanation (XXIII) -- other configurations, database initialization and service startup of neutron
猜你喜欢

Openstack explanation (XXIII) -- other configurations, database initialization and service startup of neutron

Modularnotfounderror: no module named 'find_ version’

Type-C docking station adaptive power supply patent protection case
![[TiO websocket] v. TiO websocket server counts the number of online people](/img/05/77f890a0f535ff955dffe8ca404442.jpg)
[TiO websocket] v. TiO websocket server counts the number of online people

The first TOF related data set available for deep learning: deep learning for confidence information in stereo and TOF data fusion (iccv 2017)

Shandong University project training (IV) -- wechat applet scans web QR code to realize web login

Before applying data warehouse ODBC, you need to understand these problems first

Ecological co construction | 2021 streamnational excellent partner of the year comes out!

DOS command virtual environment

Strength and appearance Coexist -- an exclusive interview with Liu Yu, a member of Apache pulsar PMC
随机推荐
Method (common method), method execution memory analysis, method overloading mechanism, method recursion
The difference and relation between machine learning and statistics
DOS command virtual environment
面试题 17.10. 主要元素
Video review pulsar summit Asia 2021, cases, operation and maintenance, ecological dry goods
OpenCV CEO教你用OAK(五):基于OAK-D和DepthAI的反欺骗人脸识别系统
Pytorch installation for getting started with deep learning
Openstack explanation (XXIII) -- other configurations, database initialization and service startup of neutron
Talk about how to customize data desensitization
Clothing ERP: how do enterprises carry out implementation planning?
1400. construct K palindrome strings
Opencv CEO teaches you to use oak (V): anti deception face recognition system based on oak-d and depthai
Revisiting Self-Training for Few-Shot Learning of Language Model,EMNLP2021
Flask (II) - route
document对象
P1169 "chessboard making"
1493. 删掉一个元素以后全为 1 的最长子数组
The mobile terminal page uses REM for adaptation
Do you know these advantages of ERP system?
Modularnotfounderror: no module named 'find_ version’