当前位置:网站首页>Two special functions (arrow function and method)
Two special functions (arrow function and method)
2022-07-28 15:55:00 【PBitW】
List of articles
The arrow function sums up

The arrow function doesn't prototype( Prototype ), So the arrow function itself doesn't have this, To get from context !
thank :Js Knowledge about ordinary functions and arrow functions
Method
Binding functions in an object , This function is called the method of this object .
stay JavaScript in , The definition of an object is as follows :
var xiaoming = {
name: ' Xiao Ming ',
birth: 1990
};
however , If we give xiaoming Bind a function , You can do more . such as , Write a age() Method , return xiaoming In the age of :
var xiaoming = {
name: ' Xiao Ming ',
birth: 1990,
age: function () {
var y = new Date().getFullYear();
return y - this.birth;
}
};
xiaoming.age; // function xiaoming.age()
xiaoming.age();
Functions bound to objects are called methods , It's no different from ordinary functions , But it uses a... Internally this keyword , What is this thing ?
Inside a method ,this It's a special variable , It always points to the current object , That is to say xiaoming This variable . therefore ,this.birth Can get xiaoming Of birth attribute .
This picture is in 01 to encounter vue There has been !
边栏推荐
- Camera continuous shooting automatic test shell script
- 兆骑科创创业大赛平台,活动路演,投融资对接
- How to compress and decompress ramdisk.img
- Software architecture and design (V) -- data centric architecture
- PXE network installation
- Minimum heap improves the efficiency of each sort
- Rust 入门指南(rustup, cargo)
- FTP file transfer protocol
- Docker实现Redis Cluster(集群)模式 哈希槽分区进行亿级数据存储
- PyQt5快速开发与实战 5.2 容器:装载更多的控件
猜你喜欢

语音社交系统——完善有声系统产业链

生命的感悟

js 链表 01

Software architecture and design (x) -- Architecture Technology

Encoder high speed pulse counter Modbus RTU module ibf150

Software architecture and design (I) -- key principles

Communication between client and server based on rsocket protocol

多用型混合信号8AI/4DI/DO转串口RS485/232MODBUS采集模块IBF30
![[channel attention mechanism] senet](/img/e6/261ca0ae5a38c26e74de27d90993f7.jpg)
[channel attention mechanism] senet

How to quickly access the unified authentication system
随机推荐
电压转电流/电流转电压模块
Docker container implements MySQL master-slave replication
虚拟机之NAT模式下设置静态IP
How to quickly access the unified authentication system
Duty cycle switch output high speed pulse counter rtumodbus module ibf63
Love programming
Has won Huawei's 8.5 billion yuan screen order? Vicino responded: the customer asked for confidentiality and could not reply!
2021 肯特面试题1
语音社交系统——完善有声系统产业链
Shell编程规范与变量
有道云笔记去除底部广告
PXE网络装机
An article about rsocket protocol
DNS域名解析协议
js 优先级队列
Have you seen the management area decoupling architecture? Can help customers solve big problems
Software architecture and design (V) -- data centric architecture
Using SYSTEMd to manage services
远距离串口服务器( 适配器)UART 转 1-Wire 应用
One channel encoder, two channels Di speed measurement, RS485 serial port connected to one channel do alarm module ibf151