当前位置:网站首页>函数和箭头函数
函数和箭头函数
2022-07-27 05:03:00 【huijie_0716】
函数
一、 函数分类:
1、有参数 有返回 var x=string.split(',');
2、无参数 有返回 var x=string.trim();
3、有参数 无返回 forEach(function(){})
4、无参数 无返回 没有
二、 函数的返回值
返回值的作用:返回上级调用者
三、最大值和最小值
var x = [2, 5, 8, 9, 22, 3, 3, 44, 24, 545];
console.log(Math.max(...x));
console.log(Math.min(...x));四、 
箭头函数
一、 匿名函数:
1、立即执行;2、方法参数,事件回调
(function() {
console.log('立即执行匿名函数');
})();
~function() {
console.log('立即执行匿名函数');
}();
!function() {
console.log('立即执行匿名函数');
}();二、点击
document.body.onclick=function(){
console.log('点击事件!!');
}
var x=[];
x.forEach(function(){
})三、 箭头函数 是匿名函数的 间写
(()=>console.log('箭头函数'))();
(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)四、 数据
var obj={
name:'张三',
birth:'2002-9-8 15:33:22',
getAage:function(){
console.log('外部函数的:',this.name);
(()=>{
console.log('内部函数的:',this.name);
})();
}
}
obj.getAage();五、按钮事件
document.querySelector('button').onclick=()=>{
console.log('onclick:',this);
}
document.querySelector('button').onclick=function(){
console.log('onclick:',this);
}
边栏推荐
- Day5 --- Flask-RESTful请求响应与SQLAlchemy基础
- Pinball games
- 图片上传的逻辑
- Li Hongyi machine learning team learning punch in activity day01 --- introduction to machine learning
- How to view the evaluation of tutors
- 使用vertical-align不能让图片和文字垂直居中对齐
- Three waiting methods of selenium and three processing methods of alert pop-up
- 分享一道关于变量的选择题(内含全局变量、局部变量、变量的作用域、生命周期知识点)
- 时间复杂度与空间复杂度
- Differences and examples between internal classes and static internal classes
猜你喜欢

Graph cuts learning

torch中乘法整理,*&torch.mul()&torch.mv()&torch.mm()&torch.dot()&@&torch.mutmal()

Pinball games

Li Hongyi machine learning team learning punch in activity day03 --- error and gradient decline

JDBC API details

Mysql速成

使用vertical-align不能让图片和文字垂直居中对齐

如何将Excel表格中的多列内容合并到一列

Sparse array → saving and continuation of Gobang

Message reliability processing
随机推荐
SQL(MySql)菜鸟教程知识
图片上传的逻辑
flask蓝图
C语言字符串介绍以及相关操作函数
背景图片相关应用-铺满,自适应
SQL (MySQL) rookie tutorial knowledge
努力进化中_我的第一篇csdn博客
块,行内块元素之间存在间隙
分享一道关于变量的选择题(内含全局变量、局部变量、变量的作用域、生命周期知识点)
redis集群
【codeforces 1695C Zero Path】DP
Pytorch data type and numpy data are mutually transformed
How to get started quickly and strengthen learning?
元素显示模式:块级,行内,行内块,嵌套规范,显示模式转换
用户-注册-登录
BIO、NIO、AIO区别
Cenos7更新MariaDB
Day3 ---Flask 状态保持,异常处理与请求钩子
后台优惠券管理
cookie增删改查和异常