当前位置:网站首页>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()边栏推荐
- Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
- 反射效率为什么低?
- IO模型复习
- 使用U2-Net深层网络实现——证件照生成程序
- [sword finger offer] 42 Stack push in and pop-up sequence
- The width of table is 4PX larger than that of tbody
- [dai6] mirror image of JZ27 binary tree
- JMeter about setting thread group and time
- Learning records - high precision addition and multiplication
- STM32 Basics - memory mapping
猜你喜欢

IO model review

STM32 ADC and DMA

Appx代碼簽名指南

1324:【例6.6】整数区间

求方程ax^2+bx+c=0的根(C语言)

Prototype object in ES6

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

Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!

求最大公约数与最小公倍数(C语言)

Leetcode exercise - 113 Path sum II
随机推荐
Remote meter reading, switching on and off operation command
【二开】【JeecgBoot】修改分页参数
The method of word automatically generating directory
OpenGL glLightfv 函数的应用以及光源的相关知识
fiddler-AutoResponder
[homework] 2022.7.6 write your own cal function
IO model review
PDF文档签名指南
About hzero resource error (groovy.lang.missingpropertyexception: no such property: weight for class)
【acwing】786. 第k个数
String formatting
[牛客网刷题 Day6] JZ27 二叉树的镜像
Use of JSON extractor originals in JMeter
Fiddler simulates the interface test
Why is the reflection efficiency low?
Review of the losers in the postgraduate entrance examination
Differences between MCU and MPU
Methods of adding centerlines and centerlines in SolidWorks drawings
This article explains the complex relationship between MCU, arm, muc, DSP, FPGA and embedded system
The mobile terminal automatically adjusts the page content and font size by setting rem