当前位置:网站首页>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 .


边栏推荐
- [turn] flying clouds_ Qt development experience
- Flat design, blog website (VIII) code source code
- Practice: how to reasonably design functions to solve practical problems in software development (I)
- Array information management system reconfiguration preheating (1) how to write basic logic using linear continuous structure?
- Implementation of customization function page of online Fox game server room configuration wizard service
- 538. convert binary search tree to cumulative tree
- UEFI finding PCI devices
- 数学方法论的含义和研究意义
- Transformer Tracking
- Simple integration of client go gin six list watch two (about the improvement of RS, pod and deployment)
猜你喜欢

Flutter Container组件
![[]==! []](/img/65/ab724c74b080da319ed5c01c93fdb7.png)
[]==! []

Won't virtual DOM be available in 2022? Introduction to virtual Dom and complete implementation of diff and patch

Deep Attentive Tracking via Reciprocative Learning
![Handwritten promise [05] - exception capture of promise method and optional parameters of then method implementation](/img/e7/87069f921ae003511e32b23653703c.jpg)
Handwritten promise [05] - exception capture of promise method and optional parameters of then method implementation

saltstack部署lnmp

Sohu employees encounter wage subsidy fraud. What is the difference between black property and gray property and how to trace the source?

socket. IO cross domain stepping pit

Drawing with qpainter

Shuttle container component
随机推荐
Flat design, blog website (VIII) code source code
1266_FreeRTOS调度器启动代码实现分析
JS implementation of graphic merging and sorting process [source code attached]
Duality-Gated Mutual Condition Network for RGBT Tracking
Wan Zichang's article shows you promise
Starting from scratch (I)
About parseint()
What are the differences and usages of break and continue?
SQL query. Only the column name is displayed but not the data
JVM from getting started to giving up 2: garbage collection
Transformer Tracking
[MATLAB image encryption and decryption] chaotic sequence image encryption and decryption (including correlation test) [including GUI source code 1862]
. Net C Foundation (6): namespace - scope with name
UEFI查找PCI设备
100. same tree
Do you know what the quotation for it talent assignment service is? It is recommended that programmers also understand
sql查询问题,只显示列名 不显示数据
Appclips & tips (continuous update)
Deep Attentive Tracking via Reciprocative Learning
数学方法论的含义和研究意义