Skip to content

Commit cd63c8a

Browse files
committed
Refresh examples
1 parent e367ae9 commit cd63c8a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

JavaScript/1-simple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
function Singleton() {
4-
const instance = Singleton.instance;
4+
const { instance } = Singleton;
55
if (instance) return instance;
66
Singleton.instance = this;
77
}

JavaScript/3-complex.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
const Singleton = (() => {
44
let instance;
55

6-
function Singleton() {
7-
if (instance) return instance;
8-
instance = this;
6+
class Singleton {
7+
constructor() {
8+
if (instance) return instance;
9+
instance = this;
10+
}
911
}
1012

11-
Singleton.prototype.test = function() {};
12-
1313
return Singleton;
1414
})();
1515

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy