当前位置:网站首页>Specific functions of some multi parameter functions
Specific functions of some multi parameter functions
2022-07-28 11:51:00 【The king of the scroll goes to war】
I can often encounter some js Function has more than one parameter , Let's tidy up today , It will be updated continuously !!!
1. addEventListener()
We know that when clicking or other events trigger , Corresponding dom The element has three stages : Capture —— The goal is —— Bubbling , The third parameter that can be distinguished is the capture phase ( From the outside in ) Or bubble stage ( From the inside out ), Similarly, we change the position of the following two functions , You can let dom Elements bubble and then capture .
addEventListener('onclick',function(){
console.log(' This is the capture phase ')
},true);
addEventListener('onclick',function(){
console.log(' This is the bubbling stage ')
},true)
2. sort
sort The method is js Array sorting ( Change the of the original array 7 One of the big methods ) Methods , Not transmitted by default , The elements in the array will follow unicode Sort . If , If we want him to rank from small to large , You can pass a function , as follows :
[1,4,2,6,4,8,6].sort((a,b)=>a-b)
In fact, this is the abbreviation of a method , If you want to know something, you can check it .
3. splice、slice
These two methods , In the array , The effect of cutting . however splice Change the original array ,slice Return a new array .
splice( Start index , How many bits are cut in total )
slice( Start index , End index ( This one is not included ))
Besides ,slice It can also be used for cutting strings .
4.setTimeout()、setInterval
setTimeout and setInterval The third parameter , Commonly used in , For internal functions ( The second parameter ) The ginseng
function sum(x, y) {
console.log(x+y) //3
}
setTimeout(sum, 1000, 1, 2, 3);
The following is actually wrong , No delay effect :
function sum(x, y) {
console.log(x + y); //3
}
setTimeout(sum(1, 2), 1000);
边栏推荐
- Three methods of using unity mouse to drive objects
- echo -ne(echo line)
- STL の 概念及其应用
- Reflect 机制获取Class 的属性和方法信息
- Are interviews all about memorizing answers?
- [极客大挑战 2019]BabySQL-1|SQL注入
- Know the optical fiber interface and supporting optical fiber cable of can optical fiber converter in fire alarm networking
- Jupiter、spyder、Anaconda Prompt 、navigator 快捷键消失的解决办法
- Function of interface test
- 数字孪生轨道交通:“智慧化”监控疏通城市运行痛点
猜你喜欢

zotero文献管理器及其使用姿势(不定时更新)

Service Workers让网站动态加载Webp图片

Top ten application development trends from 2022 to 2023

Leecode8 string conversion integer (ATOI)

Update dev (development version) of the latest win11

Are interviews all about memorizing answers?

LabVIEW AI视觉工具包(非NI Vision)下载与安装教程

Autumn recruit offer harvesters, and take the offers of major manufacturers at will
![[pyGame practice] when the end of the world comes, how long can you live in a cruel survival game that really starts from scratch?](/img/2b/1eb02249ab9ad0b4e1bfeeee87418c.png)
[pyGame practice] when the end of the world comes, how long can you live in a cruel survival game that really starts from scratch?

Six papers that must be seen in the field of target detection
随机推荐
1331. Array sequence number conversion
我想请教下各位大佬,cdc采集mysql时,如果发生了主从切换,有什么方案可以处理吗
consul安装与配置
OsCache缓存监控刷新工具
LabVIEW AI视觉工具包(非NI Vision)下载与安装教程
Google Earth engine - use geetool to download single scene images in batches and retrieve NDSI results with Landsat 8
【补题日记】[2022牛客暑期多校2]I-let fat tension
15. User web layer services (III)
Object stream of i/o operation (serialization and deserialization)
中国业务型CDP白皮书 | 爱分析报告
什么是WordPress
R language - some metrics for unbalanced data sets
PHP detects whether the URL URL link is normally accessible
14、用户web层服务(二)
301. Delete invalid brackets
Client service registration of Nacos registry
15、用户web层服务(三)
R language uses LM function to build regression model, uses the augmented function of bloom package to store the model results in dataframe, and uses ggplot2 to visualize the regression residual diagr
Let me think about Linear Algebra: a summary of basic learning of linear algebra
Ripro9.0 revised and upgraded version +wp two beautification packages + rare plug-ins