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


边栏推荐
- Use of qscriptengine class
- []==! []
- 双周投融报:资本抢滩元宇宙游戏
- 迅为干货 |瑞芯微RK3568开发板TFTP&NFS烧写(上)
- Handwritten promise [05] - exception capture of promise method and optional parameters of then method implementation
- ESP32学习笔记(49)——ESP-WIFI-MESH接口使用
- . Net C Foundation (6): namespace - scope with name
- Common troubleshooting tools and analysis artifacts are worth collecting
- 【Matlab图像融合】粒子群优化自适应多光谱图像融合【含源码 004期】
- Shuttle container component
猜你喜欢

Saltstack deployment LNMP

Redux learning (III) -- using Redux saga, writing middleware functions, and splitting reducer files

关于 QtCreator的设计器QtDesigner完全无法正常拽托控件 的解决方法

Difference between byte and bit

Mongodb installation
![[matlab WSN communication] a_ Star improved leach multi hop transmission protocol [including source code phase 487]](/img/fd/53776b550390752282cd8797193436.png)
[matlab WSN communication] a_ Star improved leach multi hop transmission protocol [including source code phase 487]

JVM from getting started to abandoning 1: memory model

Duality-Gated Mutual Condition Network for RGBT Tracking
![[probability theory and mathematical statistics] Dr. monkey's notes p41-44 statistics related topics, determination of three distributions, properties, statistics subject to normal distribution in gen](/img/93/d1014b07c924195e062dc83d69b14a.png)
[probability theory and mathematical statistics] Dr. monkey's notes p41-44 statistics related topics, determination of three distributions, properties, statistics subject to normal distribution in gen

常用问题排查工具和分析神器,值得收藏
随机推荐
Latex various arrows / arrows with text labels / variable length arrows
网狐游戏服务器房间配置向导服务定制功能页实现
arguments......
关于 QtCreator的设计器QtDesigner完全无法正常拽托控件 的解决方法
Handwritten a message queue in two ways
Flutter 内外边距
1266_FreeRTOS调度器启动代码实现分析
【LeetCode】-- 17.电话号码的字母组合
Whether the ZABBIX monitoring host is online
Flutter 约束容器组件
Cross-Modal Pattern-Propagation for RGB-T Tracking
3.1 测试函数的命名规则
Shuttle inside and outside margins
Detailed explanation of mutual call between C language and Lua
【Matlab图像融合】粒子群优化自适应多光谱图像融合【含源码 004期】
Deep Attentive Tracking via Reciprocative Learning
Illustration of JS implementation from insertion sort to binary insertion sort [with source code]
News web page display
QT script document translation (I)
[MATLAB image fusion] particle swarm optimization adaptive multispectral image fusion [including source code phase 004]