当前位置:网站首页>What happens to the new arrow function in ES6
What happens to the new arrow function in ES6
2022-07-27 05:41:00 【weixin_ forty-six million fifty-one thousand two hundred and si】
1)new Keyword execution process
- new After constructor , An empty object will be created in memory
- this It will point to the empty object just created
- Execute code in constructor , Add attribute methods to empty objects
- Return this new object ( So... Is not required in the constructor return)
2) Arrow function
In the arrow function this Is static , Point to the object where it was defined , It will not be the object at the time of call ,this The direction cannot be changed
var age=18
var obj={
age:20,
getAge(){
// Constructors , Who is calling ,this Just point to who
console.log(this.age);
},
getAge1:()=>{
//this Is static , Point to the object where it was defined (window object ), Can't be a constructor
console.log(this.age);
},
}
obj.getAge()//20
obj.getAge1()//18
边栏推荐
猜你喜欢

初识C语言——初识指针

路由的配置和前往登录首页进行发送请求

「PHP基础知识」PHP语句和语句块

布局的搭建及天气预报的显示

分享一道关于程序编译过程的选择题(内含编译过程浅谈,符号表的形成合并过程)

分享一道关于变量的选择题(内含全局变量、局部变量、变量的作用域、生命周期知识点)

「PHP基础知识」PHP中实现数学运算

初识C语言——什么是C语言

Edit delete user

Share a multiple-choice question about the process of program compilation (including a brief discussion on the compilation process, the formation and merging process of symbol tables)
随机推荐
Gallerycms download, installation and configuration
「PHP基础知识」PHP中的注释
初始C语言——关键字static的作用
一本通1319——排队接水
js进阶知识—函数
dirsearch[目录扫描工具]
C language string function: strlen, strcpy, strcat
GalleryCMS下载安装与配置
分享一道关于#define的选择题(内含#define在预编译时的替换规则,程序环境和预处理相关知识)
初识C语言——常见的数据类型
User registration login
First knowledge of C language -- what is C language
背景图片相关应用-铺满,自适应
while循环
Qsort - the sorting function in C language (with void*, callback function knowledge points
First knowledge of C language -- common data types
node 安装调试
页面布局中元素定位的几种方式
深度优先搜索(dfs)简介
User management - paging