当前位置:网站首页>Don't use array.length-1 to get the last item of the array
Don't use array.length-1 to get the last item of the array
2022-08-09 22:07:00 【Maple moving forward】
Please don't use array.length-1 to get the last item of the array. There is a more convenient and concise method: at , which is a method on the array prototype.
mdn:
Theat()
method takes an integer value and returns the item at that index, positive and negative numbers are allowed.Negative integers count down from the last item in the array.
eg:
const a = [1,2,3];const lastItem = a.at(-1);console.log(lastItem ); // 3
Negative numbers start from -1 to represent the last digit.
边栏推荐
- 大健康产业商业供应链管理系统数字化提升产业链运作效率推动供应链标准化建设
- 【深度学习】pix2pix GAN理论及代码实现
- Ankerui supports Ethernet communication, profibus communication embedded energy meter APM guiding technical requirements-Susie Week
- NetCore路由的Endpoint模式
- laravel之phpunit单元测试
- Win11找不到Internet Explore怎么办
- An overall security understanding and method of cyberspace based on connection and security entropy
- 安装多版本php(php5.6,php7.2)
- 中英文说明书丨Abbkine细胞迁移分析试剂盒
- 看完这波 Android 面试题;助你斩获心中 offer
猜你喜欢
What are the benefits of enterprise data integration?How do different industries solve the problem of data access?
如何从800万数据中快速捞出自己想要的数据?
【kali-权限提升】(4.2.6)社会工程学工具包(中):中间人攻击工具Ettercap
prometheus学习3Grafana部署及基本使用
钢材行业供应链协同管理系统提升企业上下游密切度,精细化企业内部管理
人人都可以DIY的大玩具,宏光MINIEV GAMEBOY产品力强,出行新装备
小满nestjs(第四章 前置知识装饰器-实现一个GET请求)
matlab neural network ANN classification
Access control knowledge
How to fix Windows 11 not finding files
随机推荐
新出现的去中心化科学能够为科学领域带来什么?
Overview of Security Analysis Technology for Smart Home Devices
一种基于连接和安全熵的网络空间整体安全认识和方法
LeetCode每日一题(321. Create Maximum Number)
DP-Differential Privacy概念介绍
大健康产业商业供应链管理系统数字化提升产业链运作效率推动供应链标准化建设
基于模糊PID控制器的水温控制系统仿真
[Deep learning] pix2pix GAN theory and code implementation
Definition and Basic Operations of Sequence Tables
6 g underwater channel modeling were summarized based on optical communication
matlab 神经网络 ANN 分类
PCL学习之滤波Filtering
What to do if Windows 11 can't find Internet Explorer
Cholesterol-PEG-Thiol,CLS-PEG-SH,胆固醇-聚乙二醇-巯基用于改善溶解度
【深度学习】pix2pix GAN理论及代码实现
Haven't tried line art videos this year??
【NOI模拟赛】防AK题(生成函数,单位根,Pollard-Rho)
Openharmony Lightweight System Experiment--GPIO Lighting
解决执行Command报错executable file not found in $PATH
mysql duplicate data group multiple latest records