当前位置:网站首页>(JS)数组的 pop、push、unshift、shift分别是什么?
(JS)数组的 pop、push、unshift、shift分别是什么?
2022-06-29 09:57:00 【不愿透露姓名的余菜鸟】
- Array.pop()
移除数组的最后一项,并返回移除项
let array = [1,2,3,4,5];
let x = array.pop();
console.log(x) //5
- Array.push(value)
在数组末尾添加一项并返回新数组长度
value可以是任何类型
let array = [1,2,3,4,5];
let y = array.push(66)
console.log(y) //6
- Array.shift()
移除数组首项,并返回移除项
let array = [1,2,3,4,5];
let z = array.shift();
console.log(z) //1
- Array.unshift(value)
在数组首项插入一项并返回新数组长度
value可以是任何类型
let array = [1,2,3,4,5];
let l = array.unshift(66);
console.log(l) // 6
边栏推荐
- np. astype()
- Detailed explanation of handwritten numeral recognition based on support vector machine (Matlab GUI code, providing handwriting pad)
- 如何优雅的写 Controller 层代码?
- Fully understand the volatile keyword
- STM32F1與STM32CubeIDE編程實例-超聲波測距傳感器驅動
- 这个mySQL安装的时候怎么搞去了?
- Attribute in C
- Real test = "half product + Half development"?
- 各位大佬 请教下mysqlcdc的数据不支持开窗函数吗 像row_number ,lead这种
- 宁德时代麒麟电池有着更大的野心
猜你喜欢

Buuctf-- happy New Year

Attribute in C

你的项目需要自动化测试吗?

Software test model (V model and W model)

“AI x 科学计算”进行时,华为昇思 MindSpore 赛题火热开启,等你来!

Real time value transfer from C form to another form

Free books! The best-selling book "Introduction and practice of OpenCV image processing" has been completed

《MongoDB入门教程》第02篇 MongoDB安装

全面理解Synchronized

在 2022 年找工作,毕业生们的 “最后一课”
随机推荐
Detailed explanation of handwritten numeral recognition based on support vector machine (Matlab GUI code, providing handwriting pad)
AQS之BlockingQueue源码解析
ssh密钥泄露(B模块赛题)——应用服务漏洞扫描与利用
VI退出 退出VIM 适用新手
二叉树
有人遇到FlinkCdc同步MySQL时候出现的这个问题吗?
“AI x 科学计算”进行时,华为昇思 MindSpore 赛题火热开启,等你来!
企业竞争分析的几种方法:SWOT、波特五力、PEST「建议收藏」
Numeric Keypad
每日刷题记录 (七)
【C语言进阶】动态内存管理
Ora-01950 does not have permission on tablespace
由ASP.NET Core根据路径下载文件异常引发的探究
在 2022 年找工作,毕业生们的 “最后一课”
Real time value transfer from C form to another form
Luoqingqi: has high-end household appliances become a red sea? Casati took the lead in breaking the game
WinForm uses zxing to generate QR code
Ningde era Kirin battery has greater ambition
He was in '98. I can't play with him
IO流总结