当前位置:网站首页>JS实现链式调用
JS实现链式调用
2022-07-07 08:26:00 【xinxin_csdn】
可用链式方法实现四则运算
/* 简单的链式调用 类实现*/
class Person{
constructor(){
this.name = ''
}
setName(name) {
this.name = name
return this
}
getName() {
console.log('name:==',this.name)
}
}
const person = new Person()
person.setName('zx').getName()
/*函数实现*/
function Person() {
this.name = ''
}
Person.prototype = {
setName: function(name) {
this.name = name
return this
},
getName: function() {
console.log('name:==',this.name)
}
}
const person = new Person()
person.setName('zx').getName()
边栏推荐
- IPv4套接字地址结构
- Remote meter reading, switching on and off operation command
- 关于hzero-resource报错(groovy.lang.MissingPropertyException: No such property: weight for class)
- XML configuration file parsing and modeling
- C logging method
- Trajectory planning for multi-robot systems: Methods and applications 综述阅读笔记
- Review of the losers in the postgraduate entrance examination
- JMeter about setting thread group and time
- 【STM32】STM32烧录程序后SWD无法识别器件的问题解决方法
- 搭建物联网硬件通信技术几种方案
猜你喜欢
Leetcode exercise - 113 Path sum II
Trajectory planning for multi robot systems: methods and Applications Overview reading notes
Experience sharing of software designers preparing for exams
Methods of adding centerlines and centerlines in SolidWorks drawings
【STM32】STM32烧录程序后SWD无法识别器件的问题解决方法
对word2vec的一些浅层理解
成为优秀的TS体操高手 之 TS 类型体操前置知识储备
[second on] [jeecgboot] modify paging parameters
XML configuration file parsing and modeling
P1223 排队接水/1319:【例6.1】排队接水
随机推荐
Using U2 net deep network to realize -- certificate photo generation program
STM32 Basics - memory mapping
Differences between MCU and MPU
When there are pointer variable members in the custom type, the return value and parameters of the assignment operator overload must be reference types
@Configuration, use, principle and precautions of transmission:
Hdu-2196 tree DP learning notes
施努卡:机器视觉定位技术 机器视觉定位原理
How embedded engineers improve work efficiency
施努卡:机器人视觉抓取工作原理 机器视觉抓取
Study summary of postgraduate entrance examination in October
Use the fetch statement to obtain the repetition of the last row of cursor data
MCU is the most popular science (ten thousand words summary, worth collecting)
Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
Programming features of ISP, IAP, ICP, JTAG and SWD
[STM32] solution to the problem that SWD cannot recognize devices after STM32 burning program
gym安装踩坑记录
Talking about the return format in the log, encapsulation format handling, exception handling
Serial communication relay Modbus communication host computer debugging software tool project development case
Kotlin realizes wechat interface switching (fragment exercise)
STM32 product introduction