当前位置:网站首页>数组自带的方法
数组自带的方法
2022-06-23 15:25:00 【暴躁李子 在线摆烂】
Array.prototype.at()
at() 方法接收一个整数值并返回该索引的项目,允许正数和负数。
负整数从数组中的最后一个项目开始倒数
// 一个函数,用于返回给定数组的最后一个项目
function returnLast(arr) {
return arr.at(-1);
}
const a=[{
name:'1'},{
name:'2'},{
name:'3'}]
a.at(0) // {name: '1'}
a.at(-1) // {name: '3'}
this.returnLast(a) // {name: '3'}
Array.prototype.concat()
concat() 方法用于合并两个或多个数组。此方法不会更改现有数组,而是返回一个新数组
const array1 = ['a', 'b', 'c'];
const array2 = ['a', 'e', 'f'];
const array3 = [1,2,3];
//array1.concat(array2); Array ["a", "b", "c", "a", "e", "f"]
//array1.concat(array2,array3); Array ["a", "b", "c", "a", "e", "f", 1, 2, 3]
at: ƒ at()
concat: ƒ concat()
constructor: ƒ Array()
copyWithin: ƒ copyWithin()
entries: ƒ entries()
every: ƒ every()
fill: ƒ fill()
filter: ƒ filter()
find: ƒ find()
findIndex: ƒ findIndex()
findLast: ƒ findLast()
findLastIndex: ƒ findLastIndex()
flat: ƒ flat()
flatMap: ƒ flatMap()
forEach: ƒ forEach()
includes: ƒ includes()
indexOf: ƒ indexOf()
join: ƒ join()
keys: ƒ keys()
lastIndexOf: ƒ lastIndexOf()
length: 0
map: ƒ map()
pop: ƒ pop()
push: ƒ push()
reduce: ƒ reduce()
reduceRight: ƒ reduceRight()
reverse: ƒ reverse()
shift: ƒ shift()
slice: ƒ slice()
some: ƒ some()
sort: ƒ sort()
splice: ƒ splice()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
unshift: ƒ unshift()
values: ƒ values()
Symbol(Symbol.iterator): ƒ values()
边栏推荐
- Important knowledge of golang: mutex
- Why can a high pass filter become a differentiator?
- 打印内存站信息
- MySQL日志管理怎么配置
- A transformer can only convert alternating current. How can I convert direct current?
- Half wave loss equal thickness and equal inclination interference
- Gartner最新报告:低代码应用开发平台在国内的发展
- TCP协议三次握手和四次挥手抓包分析
- MQ消息中间件理论详解
- 自监督学习(SSL)Self-Supervised Learning
猜你喜欢

Three simple tips for accelerating yarn install

Starting from 3, add paging function in the business system

他山之石 | 微信搜一搜中的智能问答技术

Moher College - manual SQL injection vulnerability test (MySQL database)

Usestate vs useref and usereducer: similarities, differences and use cases

变压器只能转换交流电,那直流电怎么转换呢?

This year's cultural entertainers have turned their sidelines into their main business

Important knowledge of golang: waitgroup parsing

JS中的pop()元素

Arrays in JS
随机推荐
Stone from another mountain - Intelligent Question and answer technology in wechat search
Embedded software architecture design - program layering
英特尔Arc A380显卡消息汇总:跑分亮眼驱动拉胯 入门性价产品亟待优化
js遍历数组(用forEach()方法)
Origin of sectigo (Comodo) Certificate
golang 重要知识:定时器 timer
[普通物理] 半波损失 等厚与等倾干涉
Sectigo(Comodo)证书的由来
labelme的JSON文件转成COCO数据集格式
电子学会图形化一级编程题解析:猫捉老鼠
golang 重要知识:RWMutex 读写锁分析
SQL窗口函数怎么使用
The running rabbit fell
stylegan2:analyzing and improving the image quality of stylegan
基因检测,如何帮助患者对抗疾病?
JS traversal array (using the foreach () method)
Print memory station information
打印内存站信息
Horizon development board commissioning
要买的理财产品年限长,划算吗?