当前位置:网站首页>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 "]
边栏推荐
- Use of MSF evaluation module
- Pytorch installation for getting started with deep learning
- Flask (II) - route
- Typescript -- preliminary study of variable declaration
- Error [detectionnetwork (1)][warning]network compiled for 6 shapes, maximum available 10, compiling for 5 S
- 服装ERP:企业如何进行施行规划?
- 2161. 根据给定数字划分数组
- [image processing] spatial domain image enhancement
- 报错RuntimeError: BlobReader error: The version of imported blob doesn‘t match graph_transformer
- Sed explanation of shell script (SED command, sed -e, sed s/ new / old /...)
猜你喜欢

Control statement if switch for while while break continue

报错RuntimeError: BlobReader error: The version of imported blob doesn‘t match graph_transformer

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

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

document对象

ESP8266_SmartConfig

Package details

Thread theory

Openstack explanation (22) -- neutron plug-in configuration

Openstack explanation (21) -- installation and configuration of neutron components
随机推荐
Device = depthai Device(““, False) TypeError: _init_(): incompatible constructor arguments.
报错Output image is bigger(1228800B) than maximum frame size specified in properties(1048576B)
Shandong University project training (IV) -- wechat applet scans web QR code to realize web login
Set up redis highly available cluster environment
POJ3250「Bad Hair Day」
Zhiyun health submitted the statement to HKEx again: the loss in 2021 exceeded 4billion yuan, an increase of 43% year-on-year
Day 47 how to query a table
OpenCV CEO教你用OAK(四):创建复杂的管道
Ecological co construction | 2021 streamnational excellent partner of the year comes out!
【ROS】noedic-moveit安装与UR5模型导入
【软件】ERP体系价值最大化的十点技巧
Revisiting Self-Training for Few-Shot Learning of Language Model,EMNLP2021
OpenCV CEO教你用OAK(五):基于OAK-D和DepthAI的反欺骗人脸识别系统
Type-C docking station adaptive power supply patent protection case
Console you don't know
Thread theory
The difference and relation between machine learning and statistics
报错Version mismatch between installed depthai lib and the required one by the scrip.
ESP8266_SmartConfig
Analysis of Kube scheduler disk scheduling source code