当前位置:网站首页>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()边栏推荐
- 小程序跳转H5,配置业务域名经验教程
- BigDecimal value comparison
- 宁愿把简单的问题说一百遍,也不把复杂的问题做一遍
- Study summary of postgraduate entrance examination in November
- IPv4套接字地址结构
- Using U2 net deep network to realize -- certificate photo generation program
- Talking about the return format in the log, encapsulation format handling, exception handling
- Easyexcel read write simple to use
- 根据设备信息进行页面跳转至移动端页面或者PC端页面
- Weekly recommended short videos: what are the functions of L2 that we often use in daily life?
猜你喜欢

基于gis三维可视化技术的智慧城市建设

Trajectory planning for multi-robot systems: Methods and applications 综述阅读笔记

小程序跳转H5,配置业务域名经验教程

Postman interface test VI

浅谈日志中的返回格式封装格式处理,异常处理

P1223 排队接水/1319:【例6.1】排队接水

Methods of adding centerlines and centerlines in SolidWorks drawings

mysql插入数据创建触发器填充uuid字段值

P2788 数学1(math1)- 加减算式

Use the fetch statement to obtain the repetition of the last row of cursor data
随机推荐
【acwing】786. Number k
2022.7.4DAY596
IDA中常见快捷键
Some superficial understanding of word2vec
Multisim--软件相关使用技巧
[daiy5] jz77 print binary tree in zigzag order
P1031 [NOIP2002 提高组] 均分纸牌
gym安装踩坑记录
PDF文档签名指南
【acwing】786. 第k个数
Several schemes of building hardware communication technology of Internet of things
Elegant controller layer code
Study summary of postgraduate entrance examination in November
High number_ Chapter 1 space analytic geometry and vector algebra_ Quantity product of vectors
【作业】2022.7.6 写一个自己的cal函数
IO model review
Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
关于hzero-resource报错(groovy.lang.MissingPropertyException: No such property: weight for class)
Study summary of postgraduate entrance examination in October
[dai6] mirror image of JZ27 binary tree