当前位置:网站首页>ES6对箭头函数的理解
ES6对箭头函数的理解
2022-08-02 00:14:00 【weixin_46051260】
1)箭头函数内的this指向是静态的,总是指向定义时所在的对象,而不是调用时,并且this指向是不可以改变的
2)this始终指向函数声明时所在作用域下的this的值
3)箭头函数不能当作构造函数,也就是不可以用new命令,否则报错
4)箭头函数不存在arguments对象,即不能使用伪数组去接受参数,可以使用rest参数代替
不适用场景:与this有关的回调,事件回调,对象方法回调
box.addEventListener('click',()=>{
console.log(this);//windows
})
使用场景:与this无关的回调,定时器,数组的方法回调
box.addEventListener('click',function(){
setTimeout(() => {
this.className='newBox'
}, 2000);
})
边栏推荐
- 青蛙跳台阶
- 基于数据驱动的变电站巡检机器人自抗扰控制
- Routing strategy
- How to design a circular queue?Come and learn~
- How does JSP use request to get the real IP of the current visitor?
- Redis - message publish and subscribe
- TCL: Pin Constraints Using the tcl Scripting Language in Quartus
- Quick solution for infix to suffix and prefix expressions
- Cyber-Physical System State Estimation and Sensor Attack Detection
- Automatic conversion of Oracle-style implicit joins to ANSI JOINs using jOOQ
猜你喜欢
随机推荐
Short video SEO optimization tutorial Self-media SEO optimization skills and methods
JSP如何使用page指令让JSP文件支持中文编码呢?
鲲鹏编译调试插件实战
字符串分割函数strtok练习
协作乐高 All In One:DAO工具大全
A simple file transfer tools
2022/08/01 学习笔记 (day21) 泛型和枚举
c语言字符和字符串函数总结(二)
JSP如何使用request获取当前访问者的真实IP呢?
Task execution control in Ansible
当奈飞的NFT忘记了Web2的业务安全
BGP first experiment
基于超参数自动寻优的工控网络入侵检测
Identify memory functions memset, memcmp, memmove, and memcpy
JSP Taglib指令具有什么功能呢?
Transient Stability Distributed Control of Power System with External Energy Storage
Multidimensional Correlation Time Series Modeling Method Based on Screening Partial Least Squares Regression of Correlation Variables
使用jOOQ将Oracle风格的隐式连接自动转换为ANSI JOIN
Pytorch seq2seq 模型架构实现英译法任务
辨析内存函数memset、memcmp、memmove以及memcpy

![[HCIP] BGP Small Experiment (Federation, Optimization)](/img/a2/0967200c69cff3b683dc0af6f314c8.png)







