当前位置:网站首页>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
边栏推荐
- SHELL
- Swoole process model diagram
- Gestion des utilisateurs de la base de données MySQL
- About modifying dual system default startup item settings
- MySQL存储系统
- One sentence introduction to Trojan horse
- 一个完整的性能测试流程
- RSA and AES
- Lantern Festival | maoqiu technology and everyone "guess riddles and have a good night"
- Today, Ali came out with 35K. It's really sandpaper that wiped my ass. it showed me my hand
猜你喜欢

Leetcode56. consolidation interval

谁不想要一个自己的博客网站呢 - 搭建博客网站wordpress

Voting vault: a new primitive for defi and Governance

Codeforces B. MEX and Array

Golang之手写web框架

What indicators should safety service engineers pay attention to in emergency response?

MySQL storage system

Xctf attack and defense world crypto advanced area

Intelligent question - horse racing question

OSPF - authentication and load balancing summary (including configuration commands)
随机推荐
Summary of 2 billion redis data migration
Leetcode search insert location
Leetcode56. consolidation interval
What do you think of the deleted chat records? How to restore the deleted chat records on wechat?
UE4_ Editor development: highlight the UI making method according to the assets dragged by the mouse (1)
Create uiactionsheet [duplicate] - creating uiactionsheet [duplicate]
ECS deployment web project
PHP knowledge points
Common NPM install errors
MySQL summary
Configure the user to log in to the device through telnet -- AAA local authentication
我做功能测试这么多年的心得
Strlen and sizeof, array length and string length, don't be silly
There is a group of students' score {99, 85, 82, 63, 60}. To add a student's score, insert it into the score sequence and keep the descending order
Official win 10 image download
Lantern Festival | maoqiu technology and everyone "guess riddles and have a good night"
Share problems solved
关于Glide加载图片模糊不清楚
谁不想要一个自己的博客网站呢 - 搭建博客网站wordpress
MySQL數據庫用戶管理