当前位置:网站首页>數組
數組
2022-06-12 23:38:00 【InfoQ】
數組常用方法
1.
push()語法
var arr = ['hello', 'world', '你好', '世界'];
var res = arr.push('新來的', '新來的2', [10, 20]);
console.log(res);
console.log(arr);
2. pop()語法
var arr = ['hello', 'world', '你好', '世界', '新來的', '新來的2'];
var res = arr.pop();
console.log(res);
console.log(arr);
3. unshift()
var arr = ['hello', 'world', '你好', '世界', '新來的', '新來的2'];
var res = arr.unshift('A');
console.log(res);
console.log(arr);
4.
shift()
var arr = ['hello', 'world', '你好', '世界', '新來的', '新來的2'];
var res = arr.shift('hello');
console.log(res);
console.log(arr);
5. reverse()
6. sort()
var arr = [1, 11, 33, 26, 51, 19, 32, 27, 15, 100]
var res = arr.sort()
console.log(arr)
边栏推荐
- Go时间格式化 赋值
- Pytorch中的梯度累加【在实验时,由于GPU显存限制,遇到batch_size不能再增大的情况。为解决该问题,使用梯度累加方法】
- Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
- Avoid using asp Net core 3.0 to inject services for startup classes
- Theory + practice will help you master the dynamic programming method
- Huawei officially entered the "front loading" stage, and the millimeter wave radar track entered the "localization +4d" cycle
- 应用最广泛的动态路由协议:OSPF
- Face detection: mtcnn
- 2022年电工(初级)操作证考试题库及在线模拟考试
- Is the stock account opened by qiniu Gang safe and reliable?
猜你喜欢

2202-簡曆制作
C语言:如何给全局变量起一个别名?

2202-简历制作

2022年电工(初级)操作证考试题库及在线模拟考试

Leetcode 2200. 找出数组中的所有 K 近邻下标(可以,一次过)

2022 electrician (elementary) operation certificate examination question bank and online simulation examination

CST learning: four element array design of circular patch antenna (III) array formation and parallel excitation

Opencv source code compilation

Introduction to message oriented middleware (message queue)

度量学习(Metric Learning)【AMSoftmax、Arcface】
随机推荐
Colab tutorial (super detailed version) and colab pro/colab pro+ usage evaluation
[redis sentinel] failed listening on port 26379 (TCP) & sentinel mode no response problem solved
PHP deletes data of the same item in a two-dimensional array
2202 - production de CV
Leetcode 890 finding and replacing patterns [map] the leetcode path of heroding
Heilongjiang Branch and Liaoning Branch of PostgreSQL Chinese community have been established!
2022 R2 mobile pressure vessel filling test questions and online simulation test
DETR(Detection with Transformers) 学习笔记
Face detection: mtcnn
[recommended collection] easy to understand graphic network knowledge - Part 1
PHP删除二维数组中相同项的数据
应用最广泛的动态路由协议:OSPF
2202-簡曆制作
For product managers, which of the two certificates, PMP and NPDP, is more authoritative?
Actual combat | inductance element positioning -- detailed explanation of Halcon and opencv implementation (with source code)
dict和set的基本操作
Ast, really fragrant
Avoid using asp Net core 3.0 to inject services for startup classes
Save state when viewpager is used with fragment fragmentpageradapter
[North Asia data recovery] data recovery cases in which the partitions disappear and the partitions are inaccessible after the server reinstalls the system