当前位置:网站首页>The difference between arrow function and ordinary function
The difference between arrow function and ordinary function
2022-06-11 06:57:00 【Xiaoman's code world】
Reference resources :https://juejin.cn/post/7050492355056664612
The arrow function doesn't [[Construct]]
- The function object is a support [[Call]] 、 [[Construct]] Objects of internal methods . Every support [[Construct]] Object of must support [[Call]], in other words , Each constructor must be a function object . therefore , Constructors can also be constructor functions or constructor objects .
therefore , Want to use... For an object new, You have to make sure that the object has [[Construct]] This internal approach . The arrow function does not [[Construct]].
Why does the arrow function not [[Construct]]
Arrow function at the beginning of design , To design a shorter function without binding this. So the arrow function is not a parameter super、this、new.target Define local binding . In the arrow function this、super、arguments And new.target These values are determined by the nearest non arrow function on the periphery .
The designer of such a function does not think it is necessary to delegate to a function that can [[Construct]] The objective function of , So the arrow function doesn't [[Construct]].
At the same time, there is no need to construct prototypes , So the arrow function doesn't exist prototype attribute .
The difference between arrow function and ordinary function
- No, this、super、arguments And new.target binding :this、super、arguments And new.target The value of is determined by the nearest non arrow function .
- Can not be new call : The arrow function doesn't [[Construct]] Method , Therefore, it cannot be used as a constructor , Use new Calling the arrow function will throw an error .
- There is no prototype : Since you can't use the arrow function new, Then he doesn't need a prototype , There is no prototype attribute .
- Can't change this:this The value of cannot be modified inside the function , The value of a function remains constant throughout its life cycle .
- No, arguments object : The arrow function doesn't arguments binding , You must rely on named or remaining arguments to access the parameters of a function .
- Duplicate named parameters are not allowed : Arrow functions are not allowed to have duplicate named arguments , Whether or not in strict mode : And relatively speaking , Traditional functions prohibit this repetition only in strict mode .


边栏推荐
- Mongodb installation
- Flutter 约束容器组件
- 无心剑汉英双语诗001.《爱》
- 【Matlab图像加密解密】混沌序列图像加密解密(含相关性检验)【含GUI源码 1862期】
- WPF data binding (IV)
- Quality-aware Feature Aggregation Networkfor Robust RGBT Tracking
- Illustrate the principle of one-way linked list and the method of JS to realize linked list [with source code]
- Completed in May, 22
- LEARNING TARGET-ORIENTED DUAL ATTENTION FOR ROBUST RGB-T TRACKING
- Pytest自动化测试-简易入门教程(01)
猜你喜欢

client-go gin的简单整合六-list-watch二(关于Rs与Pod以及Deployment的完善)

Xunwei dry goods | Ruixin micro rk3568 development board TFTP & NFS writing (Part 1)

During unity panoramic roaming, AWSD is used to control lens movement, EQ is used to control lens lifting, and the right mouse button is used to control lens rotation.

socket. IO cross domain stepping pit

Web API、DOM

Redux learning (II) -- encapsulating the connect function

【概率论与数理统计】猴博士 笔记 p41-44 统计量相关小题、三大分布的判定、性质、总体服从正态分布的统计量小题

100. same tree

Shutter restraint container assembly

.NET C#基础(6):命名空间 - 有名字的作用域
随机推荐
Flutter 内外边距
Do you use typescript or anyscript
Dynamic import
[MATLAB image encryption and decryption] chaotic sequence image encryption and decryption (including correlation test) [including GUI source code 1862]
Scripy web crawler series tutorials (I) | construction of scripy crawler framework development environment
How exactly does instanceof judge the reference data type!
Mediaextractor source code analysis of multimedia framework analysis (1)
About the principle and code implementation of Siou (review IOU, giou, Diou, CIO)
How to make time planning
Post exam summary
byte和bit的区别
sql查询问题,只显示列名 不显示数据
Zabbix 监控主机是否在线
Shell脚本之启动Nacos服务端
搜狐员工遭遇工资补助诈骗 黑产与灰产有何区别 又要如何溯源?
关于 QtCreator的设计器QtDesigner完全无法正常拽托控件 的解决方法
[]==! []
[turn] flying clouds_ Qt development experience
你知道IT人才外派服务报价是怎样的么?建议程序员也了解下
. Net C Foundation (6): namespace - scope with name