当前位置:网站首页>JS singleton mode
JS singleton mode
2022-06-24 09:51:00 【Time202051】
class LoginForm {
constructor() {
this.state = 'hide'
}
show() {
if (this.state == "show") {
return
}
this.state = 'show'
console.log(" The login box displays ");
}
hide() {
if (this.state === 'hide') {
return
}
this.state = 'hide'
console.log(" The login box is hidden ");
}
}
LoginForm.getInstance = (() => {
let instance
return () => {
if (!instance) {
instance = new LoginForm()
}
return instance
}
})()
let login1 = LoginForm.getInstance()
login1.show()
let login2 = LoginForm.getInstance()
login2.hide()
console.log(login1 === login2)

边栏推荐
- 达梦数据库如何定位锁等待问题解决方法
- Nlp-d59-nlp game D28 - I think it's OK - stage summary - mentality adjustment
- grpc本地测试联调工具BloomRPC
- Servlet快速筑基
- Literature Research Report
- 带文字的seekbar : 自定义progressDrawable/thumb :解决显示不全
- 如何提高网络基础设施排障效率,告别数据断档?
- Oracle viewing data file header SCN information
- LeetCode: 240. 搜索二维矩阵 II
- PTA猴子选大王(约瑟夫环问题)
猜你喜欢

Reasons for the failure of digital transformation and the way to success

Why is LNX of e equal to X

canvas 绘制图片

impdp导schema报ORA-31625异常处理

grpc本地测试联调工具BloomRPC

有关二叉树 的基本操作

R ellipse random point generation and drawing

How to solve multi-channel customer communication problems in independent stations? This cross-border e-commerce plug-in must be known!

编程题(持续更新)

SSH Remote Password free login
随机推荐
[Eureka registry]
实战剖析:app扫码登陆实现原理(app+网页端详细逻辑)附源码
WindowManager 简单悬浮框的实现
nVisual数字基础设施运营管理软件平台
Reasons for the failure of digital transformation and the way to success
Endgame P.O.O
js代理模式
When should gridfs be used?
字节跳动-面试官: 谈下音视频同步原理,音频和视频能绝对同步吗?
Tnsnames Ora file configuration
LeetCode: 137. Number II that appears only once
记录一下MySql update会锁定哪些范围的数据
PHP使用递归和非递归方式实现创建多级文件夹
百度AI模板 获取知识理解
LeetCode: 240. Search 2D matrix II
PRCT-1400 : 未能执行 getcrshome解决方法
PostgreSQL
SSH Remote Password free login
数组无缝滚动demo
使用Live Chat促進業務銷售的驚人技巧