当前位置:网站首页>数组
数组
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)

边栏推荐
- Redis实现短信验证码登录
- Message queue directory
- The "fourteenth five year plan" development plan and panoramic strategic analysis report of China's information and innovation industry 2022 ~ 2028
- PostgreSQL 中文社区黑龙江分会和辽宁分会成立啦!
- InfoQ 极客传媒 15 周年庆征文|简述构建微服务架构的四大挑战
- Dry goods sharing | BitSet application details
- 基于Three.js海上风电数字孪生三维效果
- So, what is the difference between e.target and e.currenttarget?
- 2022年电工(初级)操作证考试题库及在线模拟考试
- 細數攻防演練中十大關鍵防守點
猜你喜欢
How to package a colorpicker component for color selection?
Redis realizes SMS verification code login
PostgreSQL 中文社区黑龙江分会和辽宁分会成立啦!
Ast, really fragrant
Don't write about the full screen explosion, try the decorator mode, this is the elegant way!!
iShot
ASP. Net core Middleware
Zhengzhou University of light industry -- development and sharing of harmonyos pet health system
Develop a web office suite from scratch (5): mouse hover over text
[opencv learning] use the Tesseract OCR movement to recognize numbers
随机推荐
LeetCode 146. LRU cache
Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
人脸检测:MTCNN
应用最广泛的动态路由协议:OSPF
PyTorch常用参数初始化方法:【均匀分布、正态(高斯)分布、Xavier、kaiming、正交矩阵、稀疏矩阵、常数、单位矩阵、零填充】
CST learning: four element array design of circular patch antenna (II) array formation and combination results
Message queue directory
[kubernetes guide ⑤] label quick start
Avoid using asp Net core 3.0 to inject services for startup classes
[Yugong series] wechat applet in February 2022 - Reference
lua 条件语句
About three-tier architecture and MVC
[literature translation - Part] revealing the structure of clinical EEG signals by self supervised learning (SSL and RP principles / data / preprocessing)
The fate of Internet people is that it is difficult to live to 30?
2202 - production de CV
Chapter 8 - shared model JUC
Module 8 operation
Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
1111111111111111111111111111111111111111111111111111111
So, what is the difference between e.target and e.currenttarget?