当前位置:网站首页>ES6 array
ES6 array
2022-06-30 06:04:00 【SignalFire】
1、 Pseudo array to array
(1)Array.prototype.slice.call()
let divs = document.getElementsByTagName("div");
let arr = Array.prototype.slice.call(divs);
console.log(arr);
(2)Array.from()
let arrObj = {
1:"aa",
0:"bb",
length:2
}
let arr = Array.from(arrObj);
console.log(arr);
(3)Array.of()
let arr = Array.of(1,"a",false,[2,3],{a:"asdf"});
console.log(arr);
let arr = Array.of(1,2,3,4);
console.log(arr);
2、 Element substitution
(1)arr.copyWithin(i,j1[,j2]) use j1 To j2 Element replacement from i Start with the corresponding element ,j2 Ellipsis j1 To the end
let arr = [0,1,2,3,4,5,6,7,8,9];
arr = arr.copyWithin(2,5,7);
console.log(arr);
(2)arr.fill(newVal[,j1,j2]) use newVal Replacement from j1 To j2 The elements of ,j1,j2 Replace all elements without writing
let arr = [0,1,2,3,4,5,6,7,8,9];
arr = arr.fill("newVal",5,8);
console.log(arr);
3、 Check whether the element exists
includes(item)
let arr = [1,2,3,NaN]
console.log(arr.includes(NaN));
indexOf Can 't detect NaN
边栏推荐
- About modifying dual system default startup item settings
- Who doesn't want a blog site of their own - build a blog site WordPress
- ES6扩展运算符(...)
- [OSPF] comparison between rip and OSPF
- At the beginning of 2022, people who are ready to change jobs should pay attention to
- [GPU] basic operation of GPU (I)
- Official win 10 image download
- C language code record
- 观察者模式、状态模式在实际工作中的使用
- [secretly kill little partner pytorch20 days] - [day4] - [example of time series data modeling process]
猜你喜欢

Beauty of Refactoring: when multithreaded batch processing task lifts the beam - Universal scaffold

SHELL

接口中方法详解

MySQL日志管理、数据备份、恢复

UE4_ Editor development: highlight the UI making method according to the assets dragged by the mouse (1)

Prototype and prototype chain in JS

MySQL advanced SQL statement
![[MD editing required] welcome to the CSDN markdown editor](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[MD editing required] welcome to the CSDN markdown editor

Using lazy < t > in C # to realize singleton mode in WPF

Talking about the struct of go
随机推荐
Cisco VXLAN配置
Cisco vxlan configuration
Share problems solved
Here comes the nearest chance to Ali
电脑查看WiFi使用密码
MySQL數據庫用戶管理
Using lazy < t > in C # to realize singleton mode in WPF
MySQL summary
拼多多店铺搜索相关问题,为什么新品上架搜索不到
网络基础知识
880. 索引处的解码字符串
【LeetCode】236. Nearest common ancestor of binary tree
[database] transaction
MySQL transaction
Beauty of Refactoring: when multithreaded batch processing task lifts the beam - Universal scaffold
VIM view file code
[GPU] basic operation
Swoole process model diagram
The average salary of software testing in 2022 has been released. Have you been averaged?
Summary of 2 billion redis data migration