当前位置:网站首页>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);
边栏推荐
- Several reincarnation stories
- In order to ensure the normal operation of fire-fighting equipment in large buildings, the power supply monitoring system of fire-fighting equipment plays a key role
- Tiktok programmer confession special code tutorial (how to play Tiktok)
- Using C language to realize bidirectional linked list
- 多线程与高并发(三)—— 源码解析 AQS 原理
- jar 包内文件的遍历以及文件的拷贝
- [applet] how to notify users of wechat applet version update?
- STM32 drives st7701s chip (V ⅰ V0 mobile phone screen change price)
- Shell (I)
- R language ggplot2 visualization: use the ggboxplot function of ggpubr package to visualize the box diagram and customize the fill parameter to configure the filling color of the box
猜你喜欢

Consumer installation and configuration

Localization, low latency, green and low carbon: Alibaba cloud officially launched Fuzhou data center

保障邮箱安全,验证码四个优势

Leecode8 string conversion integer (ATOI)

Outlook suddenly becomes very slow and too laggy. How to solve it

中国业务型CDP白皮书 | 爱分析报告

Ripro9.0 revised and upgraded version +wp two beautification packages + rare plug-ins

The fifth generation verification code of "cloud centered, insensitive and extremely fast" is coming heavily
![[applet] how to notify users of wechat applet version update?](/img/04/848a3d2932e0dc73adb6683c4dca7a.png)
[applet] how to notify users of wechat applet version update?

PFP会是数字藏品的未来吗?
随机推荐
A hundred flowers bloom in data analysis engines. Why invest heavily in Clickhouse?
一文看懂设备指纹如何防篡改、防劫持
R language uses LM function to build regression model with interactive items, and uses: sign (colon) to represent the interaction of variables (colon is pure multiplication, excluding the constituent
【补题日记】[2022牛客暑期多校2]D-Link with Game Glitch
Who's the big God help? Let's see how Oracle number type parsing works. Struct{scale=15, Val
Guys, ask me, this can't be checkpoint, because there is a JDBC task whose task status is finished,
Understand how to prevent tampering and hijacking of device fingerprints
Outlook suddenly becomes very slow and too laggy. How to solve it
Object stream of i/o operation (serialization and deserialization)
Static proxy instance
I want to ask you guys, if there is a master-slave switch when CDC collects mysql, is there any solution
Good use explosion! The idea version of postman has been released, and its functions are really powerful
Redis安装
Five Ali technical experts have been offered. How many interview questions can you answer
Reflect 机制获取Class 的属性和方法信息
Solutions to the disappearance of Jupiter, spyder, Anaconda prompt and navigator shortcut keys
An example of the mandatory measures of Microsoft edge browser tracking prevention
Introduction to the usage of SAP ui5 image display control avatar trial version
Anonymous implementation class object of interface
STL の 概念及其应用