当前位置:网站首页>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);
}
边栏推荐
- Qt Creator代码风格插件Beautifier
- You may need an additional loader to handle the result of these loaders.
- Shenzhi Kalan Temple
- Five day travels to Beijing
- 好吃难吃饱七分为宜;好喝难喝醉三分为佳
- C commissioned use cases
- PHP realizes data interaction with MySQL
- Use of "PHP Basics" Boolean
- 北京五日游记
- Risk control and application of informatization project
猜你喜欢
随机推荐
Luogu Taotao picks apples
All in one 1353 -- expression bracket matching (stack)
1024 | in the fourth year officially called Menon, the original intention is still there, and continue to move forward
One book 1201 Fibonacci sequence
Virtual machine cloning
[MRCTF2020]Ezpop 1
海量数据肖枫:共建共治openGauss根社区,共享欣欣向荣新生态
Teach you to build a nail warning robot hand in hand
containerd拉取私库镜像失败(kubelet)
Vcenter7.0 installation of ibm3650m4 physical machine
CommonTitleBar hide left right
[target detection] yolov6 theoretical interpretation + practical test visdrone data set
End of year summary
How to log in multiple wechat on the computer
The third letter to the little sister of the test | Oracle stored procedure knowledge sharing and test instructions
Graph node deployment and testing
Stored procedure trial 2 -- establish a test table to test different types of stored procedures
好吃难吃饱七分为宜;好喝难喝醉三分为佳
QingChuang technology joined dragon lizard community to build a new ecosystem of intelligent operation and maintenance platform
C event usage case subscription event+=








