当前位置:网站首页>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
边栏推荐
- Common address collection
- Develop stylelint rules from zero (plug-ins)
- Summary of 2 billion redis data migration
- 观察者模式、状态模式在实际工作中的使用
- Finally someone can make the server so straightforward
- Title: enter two positive integers m and N to find their maximum common divisor and minimum common multiple
- Create uiactionsheet [duplicate] - creating uiactionsheet [duplicate]
- [MD editing required] welcome to the CSDN markdown editor
- Variable parameters of go
- PC viewing WiFi password
猜你喜欢

Codeforces B. MEX and Array

Mariadb数据库的安装与初始化

MySQL transaction

Dao -- a beautiful new world?

OSPF - authentication and load balancing summary (including configuration commands)

Switch to software testing and report to the training class for 3 months. It's a high paying job. Is it reliable?
![[ansible series] fundamentals 02 module debug](/img/99/c53be8e2a42c7cb5b4a9a7ef4ad98c.jpg)
[ansible series] fundamentals 02 module debug

Mysql database user management

从零开发 stylelint规则(插件)
![[deep learning] data segmentation](/img/16/798881bbee66faa2fb8d9396155010.jpg)
[deep learning] data segmentation
随机推荐
1380. lucky numbers in matrices
Huxiaochun came to fengshu electronics to sign a strategic cooperation agreement with Zoomlion
[road of system analyst] collection of wrong topics in Project Management Chapter
What do you think of the deleted chat records? How to restore the deleted chat records on wechat?
Network basics
Mariadb数据库的安装与初始化
SparseArray
MySQL storage system
Create priority queue
Develop stylelint rules from zero (plug-ins)
Master slave synchronization of MySQL database to realize read-write separation
【学习强化学习】总目录
MySQL log management, data backup and recovery
数据读写:Unity中基于C#脚本实现数据读写功能
Learning automation ppt
requests. The difference between session () sending requests and using requests to send requests directly
At the beginning of 2022, people who are ready to change jobs should pay attention to
Luogup2756 pilot pairing scheme problem (maximum flow)
UE4_ Editor development: highlight the UI making method according to the assets dragged by the mouse (1)
Create uiactionsheet [duplicate] - creating uiactionsheet [duplicate]