当前位置:网站首页>数组
数组
2022-06-12 23:37: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)
边栏推荐
- The fate of Internet people is that it is difficult to live to 30?
- CST learning: four element array design of circular patch antenna (III) array formation and parallel excitation
- China's new generation information technology industry "14th five year plan" special planning and innovation strategic direction report 2022 ~ 2028
- Leetcode 2164. 对奇偶下标分别排序(可以,一次过)
- [kubernetes guide ⑤] label quick start
- 同花顺开证券账户怎么样?到底安不安全呢
- 度量学习(Metric Learning)【AMSoftmax、Arcface】
- [recommended collection] easy to understand graphic network knowledge - Part 1
- Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
- LeetCode 146. LRU cache
猜你喜欢

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

基于Three.js海上风电数字孪生三维效果

Alien skin exposure X7 color filter plug-in, raw post-processing tool

ASP. Net core Middleware

Common message oriented middleware selection

Don't write about the full screen explosion, try the decorator mode, this is the elegant way!!

〖Kubernetes指南④〗Pod快速入门

The development trend of digital collections!

Leetcode1601: the maximum number of building change requests that can be reached (difficult)

Ast, really fragrant
随机推荐
Sequence maximum return
2202 resume making
Opencv source code compilation
Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
[opencv learning] use the Tesseract OCR movement to recognize numbers
Theory + practice will help you master the dynamic programming method
House raiding 2
Avoid using asp Net core 3.0 to inject services for startup classes
Industry reshuffle, a large number of programmers are going to lose their jobs? How can we break the current workplace dilemma
线上真实排队系统重构案例分享——实战篇
Develop a web office suite from scratch (5): mouse hover over text
LeetCode —— 26. Remove duplicates from an ordered array
Insight into China's smart medical industry in 2022
Comprehensive analysis of C array
模型过拟合-解决方案(二):Dropout
Record 5 - the serial port of stm32f411ceu6 realizes the sending and receiving of fixed length data and variable length data
Hongmeng starts
Ten key defensive points in the detailed attack and defense drill
Unprecedented analysis of Milvus source code architecture
AWS lambda: how to store secrets to external APIs- AWS Lambda: How to store secret to external API?