当前位置:网站首页>Js array commonly used API
Js array commonly used API
2022-07-29 11:49:00 【IT worker】
var color = [“red”,”green”,”blue”];
var color2 = [“yellow”,”black”,”brown”];
var color3 = color.concat(color2); // concat is the content of the array passed in the parameter spliced after the caller,不修改原数组
var color4 = color.toString();// Arrays are converted to comma-connected strings
var color5 = color.join(‘+’);// Convert data to a string concatenated with parameters
var color6 = “red,green+blue”;
var color7 = color6.split(‘+’);// Convert a string to an array by argument
console.log(color); // [“red”, “green”, “blue”]
console.log(color2); // [“yellow”, “black”, “brown”]
console.log(color3); // [“red”, “green”, “blue”, “yellow”, “black”, “brown”]
console.log(color4); // red,green,blue
console.log(color5); // red+green+blue
console.log(color7); // [“red,green”, “blue”]
// slice() copy a piece of the original array,From the start position of the start parameter,to the end of the parameter, 不包括结束位置, 不改变原数组
var arr = [{“name”: “aa”}, {“age”: 12}];
console.log(arr.slice(1, 2)); // [{“age”: 12}]
console.log(arr); // [{“name”: “aa”}, {“age”: 12}]
// splice() Truncate a segment of the original array and return a new array, 修改原数组, [起始下标, 切割个数]
var arr1 = [1,2,3];
console.log(arr1.splice(0,2)); // [1, 2]
console.log(arr1) // [3]
// reverse() 反转数组 改变原数组
var arr2 = [1,5,4];
var arr22 = arr2.reverse();
console.log(arr22); // [4, 5, 1]
console.log(arr2); // [4, 5, 1]
边栏推荐
猜你喜欢

Paddlelite compilation and code running through the disk

DNS protocol, ICMP protocol, NAT technology

如何开始为您的 Kubernetes 应用程序编写 Helm 图表

Std:: vector copy, append, nested access

puzzle(017.5)联动归位

Insights into the development of the enterprise live broadcast industry in 2022
![[image detection] Research on cumulative weighted edge detection method based on gray image, with matlab code](/img/c1/f962f1c1d9f75732157d49a5d1d0d6.png)
[image detection] Research on cumulative weighted edge detection method based on gray image, with matlab code

Similarities and differences of QWidget, qdialog and qmainwindow

微信云托管入门与实践

2022年企业直播行业发展洞察
随机推荐
TCP和UDP
Gbase8s core data backup
Learning with Recoverable Forgetting阅读心得
TCP and UDP
企业微信客户朋友圈一天可以发多少条?都有哪些限制?如何突破朋友圈可展示人数限制?
js 数组常用API
Self collection online computer wallpaper PHP source code v2.0 adaptive end
The interviewer training courseware (very practical in-house training courseware)
PL/SQL 集合
【每日SQL打卡】DAY 20丨查询球队积分【难度中等】
Proficient in audio and video development can really do whatever you want
PL/SQL 事务
Alluxio为Presto赋能跨云的自助服务能力
golang 实现文件上传下载
Peking University open classes are coming! Welcome to the "AI for science" class
mysql single-line, multi-line subquery
Collections.singletonList(T o)
MFC学习备忘
共建共享数字世界的根:阿里云打造全面的云原生开源生态
AI全流程开发难题破解之钥