当前位置:网站首页>JS arrow function user and processing method of converting arrow function into ordinary function
JS arrow function user and processing method of converting arrow function into ordinary function
2022-04-23 20:25:00 【First code】
1 Arrow function
The arrow function is ES6 New functional forms appear
namely , Use ES6 Arrow function Syntax definition function , The original function of the “function” Delete the keyword and function name , And use “=>” Connecting parameter lists and function bodies .
Such as : Definition of ordinary function
var fn1 = function(a, b) {
return a + b
}
function fn2(a, b) {
return a + b
}
Arrow function definition , by
var fn1 = (a, b) => {
return a + b
}
(a, b) => {
return a + b
}
Detailed instructions , Reference resources :ES6 New feature arrow function syntax 、 How to use arrow function correctly
2 Arrow function to ordinary function
Arrow function
this.$get('/posts').then(res=>{
console.log(this)
this.datalist=res.data
})
Convert to ordinary function : Recuperation function(),res Just as one of the parameters
this.$get('/posts').then(function(res){
console.log(this)
})
3 Particular attention This The direction of
Ordinary function : Which object calls a normal function , Ordinary functions point to this object .
Arrow function : Arrowhead function this Is the upper level object of inheritance .
Two of the above code this Object pointing is different , Specifically, you can try .
Reference resources :
JS The difference between ordinary function and arrow function
ES6 New feature arrow function syntax 、 How to use arrow function correctly
版权声明
本文为[First code]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210551267601.html
边栏推荐
- Three. Based on ply format point cloud voxel model JS upload interface writing
- ArcGIS js api 4. X submergence analysis and water submergence analysis
- Customize timeline component styles
- Fundamentals of network communication (LAN, Wan, IP address, port number, protocol, encapsulation and distribution)
- Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
- 【栈和队列专题】—— 滑动窗口
- CVPR 2022 | querydet: use cascaded sparse query to accelerate small target detection under high resolution
- 6-5 字符串 - 2. 字符串复制(赋值) (10 分)C语言标准函数库中包括 strcpy 函数,用于字符串复制(赋值)。作为练习,我们自己编写一个功能与之相同的函数。
- Tensorflow 2 basic operation dictionary
- Matlab analytic hierarchy process to quickly calculate the weight
猜你喜欢
Modeling based on catiav6
Identification of bolt points in aerial photography based on perception
DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind
16MySQL之DCL 中 COMMIT和ROllBACK
Numpy Index & slice & iteration
16MySQL之DCL 中 COMMIT和ROllBACK
RT-1052学习笔记 - GPIO架构分析
波场DAO新物种下场,USDD如何破局稳定币市场?
Some basic configurations in interlij idea
CVPR 2022 | querydet: use cascaded sparse query to accelerate small target detection under high resolution
随机推荐
内网渗透之DOS命令
An error is reported when sqoop imports data from Mysql to HDFS: sqlexception in nextkeyvalue
Redis cache penetration, cache breakdown, cache avalanche
Mysql database backup scheme
Latest investigation and progress of building intelligence based on sati
2022DASCTF Apr X FATE 防疫挑战赛 CRYPTO easy_real
star
Handwritten Google's first generation distributed computing framework MapReduce
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
bounding box iou
Experience of mathematical modeling in 18 year research competition
Devexpress 14.1 installation record
An error is reported in the initialization metadata of the dolphin scheduler -- it turns out that there is a special symbol in the password. "$“
Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 64
Commit and ROLLBACK in DCL of 16mysql
Recommend an open source free drawing software draw IO exportable vector graph
PCL点云处理之基于PCA的几何形状特征计算(五十二)
Identification of bolt points in aerial photography based on perception
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
Tensorflow 2 basic operation dictionary