当前位置:网站首页>Functions and arrow functions
Functions and arrow functions
2022-07-27 08:18:00 【huijie_ 0716】
function
One 、 The function classification :
1、 With parameters There is a return var x=string.split(',');
2、 No parameter There is a return var x=string.trim();
3、 With parameters No return forEach(function(){})
4、 No parameter No return No,
Two 、 The return value of the function
The function of return value is : Return to superior caller
3、 ... and 、 Maximum and minimum
var x = [2, 5, 8, 9, 22, 3, 3, 44, 24, 545];
console.log(Math.max(...x));
console.log(Math.min(...x)); Four 、 
Arrow function
One 、 Anonymous functions :
1、 Execute now ;2、 Method parameter , Event callback
(function() {
console.log(' Execute anonymous functions now ');
})();
~function() {
console.log(' Execute anonymous functions now ');
}();
!function() {
console.log(' Execute anonymous functions now ');
}();Two 、 Click on
document.body.onclick=function(){
console.log(' Click event !!');
}
var x=[];
x.forEach(function(){
})3、 ... and 、 Arrow function Anonymous function Interleave
(()=>console.log(' Arrow function '))();
(a=>console.log('a:',a))(5);
((a,b)=>console.log('a:',a,'b',b))(5,7);
var x=(()=>{return 'qiku';})();
var x=(()=>'qiku')();
console.log(x)Four 、 data
var obj={
name:' Zhang San ',
birth:'2002-9-8 15:33:22',
getAage:function(){
console.log(' Of external functions :',this.name);
(()=>{
console.log(' Of internal functions :',this.name);
})();
}
}
obj.getAage();5、 ... and 、 Button event
document.querySelector('button').onclick=()=>{
console.log('onclick:',this);
}
document.querySelector('button').onclick=function(){
console.log('onclick:',this);
}
边栏推荐
- 帮忙发几个招聘,有兴趣可以看看
- 2020国际机器翻译大赛:火山翻译力夺五项冠军
- 1176 questions of Olympiad in informatics -- who ranked K in the exam
- Stored procedure test 1 -- first acquaintance of love
- Introduction, installation and use of netdata performance monitoring tool
- 信息化项目风险控制与应用
- XxE & XML vulnerability
- Design and development of GUI programming for fixed-point one click query
- [ciscn2019 southeast China division]web11 1
- IBM3650M4实体机安装VCenter7.0
猜你喜欢
![[geek challenge 2019] finalsql 1](/img/a7/857d47639fcb38e0055a2444206b8c.png)
[geek challenge 2019] finalsql 1

好吃难吃饱七分为宜;好喝难喝醉三分为佳

Sword finger offer 58 - I. flip word order

Leetcode56. Consolidation interval
Why do major domestic manufacturers regard cloud computing as a pastry? Do you really understand this trillion market

DEMO:ST05 找文本ID 信息

Use of string type "PHP Basics"
![[NPUCTF2020]ReadlezPHP 1](/img/d9/590446b45f917be3f077a9ea739c20.png)
[NPUCTF2020]ReadlezPHP 1

一文速览EMNLP 2020中的Transformer量化论文

How to obtain the cash flow data of advertising services to help analyze the advertising effect?
随机推荐
代码接口自动化的有点
All in one 1329 cells (breadth first search)
2022-07-26 group 4 abstract classes and interfaces
STM32小bug汇总
On data security
redis配置文件下载
Combined use of C WinForm form form event and delegate
阿里云国际版回执消息简介与配置流程
[ciscn2019 southeast China division]web11 1
idea远程调试
带宽 与 货币
Ubuntu: install PostgreSQL
All in one 1353 -- expression bracket matching (stack)
我用字符画出了一个谷爱凌!
How to obtain the cash flow data of advertising services to help analyze the advertising effect?
Luogu Taotao picks apples
Breadth first search
ERP production operation control Huaxia
Apache SSI remote command execution vulnerability
"PHP Basics" uses echo statements to output information