当前位置:网站首页>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 !
边栏推荐
- 已拿下华为85亿元屏幕订单?维信诺回应:客户要求保密,无法回复!
- Record Clearfix clear float
- 多用型混合信号8AI/4DI/DO转串口RS485/232MODBUS采集模块IBF30
- 跟我学Rx编程——Concat
- What is the concept of game testing? What are the test methods and processes?
- js 栈
- MicTR01 Tester 开发套件(振弦采集读数仪)使用说明
- Perception of life
- H265 streaming on OBS
- 0-75mv/0-100mv to rs485/232 communication interface Modbus RTU acquisition module ibf8
猜你喜欢

FTP file transfer protocol

js 数组(总结)

js 双向链表 01

Software architecture and design (VI) -- hierarchy

A tour of grp:05 - GRP server streaming service end stream

Open light input / relay output rs485/232 remote data acquisition IO module ibf70

生命的感悟

Software architecture and design (I) -- key principles

MySQL add and delete indexes

Using SYSTEMd to manage services
随机推荐
Duty cycle switch output high speed pulse counter rtumodbus module ibf63
MicTR01 Tester 开发套件(振弦采集读数仪)使用说明
Learn RX programming from me -- concat
以太网转RS485串口计数器WiFI模块 LED灯光控制器IBF165
One channel encoder, two channels Di speed measurement, RS485 serial port connected to one channel do alarm module ibf151
Software architecture and design (I) -- key principles
2021 亚鸿笔试题2
记录一下 clearfix 清除浮动
How as makes intelligent prompts regardless of case
Voice social system -- improve the audio system industry chain
两种特殊函数(箭头函数和方法)
Software architecture and design (VI) -- hierarchy
Set static IP in NAT mode of virtual machine
[live broadcast reservation] a new challenge under the evolution of data architecture - Shanghai railway station
js 双向链表 01
Leetcode bracket validity problem
How to build opengrok code server
虚拟机之NAT模式下设置静态IP
Have you seen the management area decoupling architecture? Can help customers solve big problems
Principle and application of low cost / small volume module rs485/232 to analog signal ibf33