当前位置:网站首页>数组
数组
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)
边栏推荐
- Automatically obtain the position offset of member variables inside the structure
- So, what is the difference between e.target and e.currenttarget?
- 同花顺开证券账户怎么样?到底安不安全呢
- C语言:如何给全局变量起一个别名?
- Go时间格式化 赋值
- Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
- iShot
- 同花顺股票账户开户安全吗
- Teach you how to grab ZigBee packets through cc2531 and parse encrypted ZigBee packets
- 2022 questions d'examen pour le personnel de gestion de la sécurité de l'unit é de gestion des produits chimiques dangereux et examen de simulation en ligne
猜你喜欢

Alien skin exposure X7 color filter plug-in, raw post-processing tool
![[opencv learning] small ticket recognition based on perspective transformation and OCR recognition](/img/47/08b9dd9dbea9e9cb6deda975f4d652.jpg)
[opencv learning] small ticket recognition based on perspective transformation and OCR recognition

iShot

The programmer has worked for 7 years. At the age of 31, he has no choice but to deliver takeout. I really don't want you to go through his journey again

Insight into China's smart medical industry in 2022
![[recommended collection] easy to understand graphic network knowledge - Part 1](/img/5a/dc9f1fd6cfdc1350f757b70e368fe3.png)
[recommended collection] easy to understand graphic network knowledge - Part 1

Design a MySQL table for message queue to store message data
![[opencv learning] perspective transformation matrix](/img/6e/7a53b257f6baafe8a3ae21cd0fe340.jpg)
[opencv learning] perspective transformation matrix

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

2022年G3锅炉水处理考题模拟考试平台操作
随机推荐
Restrictions on MySQL function creation
2202-简历制作
CV—BaseLine总结(从AlexNet到SENet的发展历程)
〖Kubernetes指南④〗Pod快速入门
Lua date time
1111111111111111111111111111111111111111111111111111111
PostgreSQL 中文社区黑龙江分会和辽宁分会成立啦!
移动安全必备之CS呢【NETHUNTER】
Introduction to message oriented middleware (message queue)
Lua loop statement
Bit_ Binary number
Avoid using asp Net core 3.0 to inject services for startup classes
[issue 30] shopee golang development experience
lua 日期时间
Model over fitting - solution (II): dropout
Preparing for the Blue Bridge Cup Day11__ Basic operation of serial port communication
Embedded pipeline out of the box
Zhengzhou University of light industry -- development and sharing of harmonyos pet health system
Global and Chinese Melamine Industry Development Research and prospect trend report 2022-2028
Sword finger offer series - 47 Maximum value of gifts