当前位置:网站首页>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]
边栏推荐
猜你喜欢

std::vector 拷贝、追加、嵌套访问

Alluxio为Presto赋能跨云的自助服务能力

How to use "copy – link" to accelerate docker to build and optimize cache

QML(一):自定义圆角按钮的处理

迁徙数据平台简单介绍
Xiaoxiao authorization system V5.0 happy version

TCP和UDP
小笑授权系统V5.0开心版

考完PMP后有什么益处

Peking University open classes are coming! Welcome to the "AI for science" class
随机推荐
Deep understanding of c # delegate into the fast lanes
宝塔快速搭建自适应咖啡网站模板与管理系统源码实测
Kubernetes基本概念
【每日SQL打卡】DAY 27丨每次访问的交易次数【难度困难-提前放出来】
fastjson使用方法
three.js 报错信息 RGBELoader.js:46 RGBELoader Bad File Format: bad initial token
c语言:来实现一个小程序n子棋(已五子棋为例)
解决 Chrome 浏览器被毒霸篡改问题
【表达式计算】表达式计算问题的通用解法(练习加强版,含总结)
如何对SQuAD1.1数据集进行预处理「详解版」
WPF 实现平移控件
共建共享数字世界的根:阿里云打造全面的云原生开源生态
2.3插入排序
微信怎么知道别人删除了你?批量检测方法(建群)
HMS Core Discovery 16 review | with tiger mound, embracing new AI "voice" state
【每日SQL打卡】DAY 21丨报告系统状态的连续日期【难度困难】
mapbox 地图 生成矢量数据圆
7月3日文: 表面上有危险,实属安全周期,大概率会快速上扬的个股
测试环境要多少,从现实需求说起
Building and sharing the root of the digital world: Alibaba Cloud builds a comprehensive cloud-native open source ecosystem