当前位置:网站首页>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()边栏推荐
- STM32 product introduction
- Leetcode-560: subarray with sum K
- [STM32] solution to the problem that SWD cannot recognize devices after STM32 burning program
- 2022.7.6DAY598
- 【作业】2022.7.6 写一个自己的cal函数
- 移动端通过设置rem使页面内容及字体大小自动调整
- 字符串格式化
- [dai6] mirror image of JZ27 binary tree
- Talking about the return format in the log, encapsulation format handling, exception handling
- Pdf document signature Guide
猜你喜欢

Programming features of ISP, IAP, ICP, JTAG and SWD
![[second on] [jeecgboot] modify paging parameters](/img/59/55313e3e0cf6a1f7f6b03665e77789.png)
[second on] [jeecgboot] modify paging parameters

Talking about the return format in the log, encapsulation format handling, exception handling

The Hal library is configured with a general timer Tim to trigger ADC sampling, and then DMA is moved to the memory space.

leetcode-304:二维区域和检索 - 矩阵不可变

对word2vec的一些浅层理解

Encrypt and decrypt stored procedures (SQL 2008/sql 2012)

Remote meter reading, switching on and off operation command

Inno Setup 打包及签名指南

IO模型复习
随机推荐
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
ThreadLocal会用可不够
施努卡:机器视觉定位技术 机器视觉定位原理
[detailed explanation of Huawei machine test] tall and short people queue up
Serial communication relay Modbus communication host computer debugging software tool project development case
Factorial implementation of large integer classes
IO模型复习
Study summary of postgraduate entrance examination in October
字符串格式化
Why is the reflection efficiency low?
P2788 数学1(math1)- 加减算式
施努卡:机器视觉定位技术 机器视觉定位原理
I'd rather say simple problems a hundred times than do complex problems once
Appx代码签名指南
Slurm资源管理与作业调度系统安装配置
[牛客网刷题 Day6] JZ27 二叉树的镜像
【剑指Offer】42. 栈的压入、弹出序列
Study summary of postgraduate entrance examination in July
About hzero resource error (groovy.lang.missingpropertyexception: no such property: weight for class)
成为优秀的TS体操高手 之 TS 类型体操前置知识储备