FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
javascript-things/DesignPatterns/ModulePattern/index.js at master · karan1205/javascript-things · GitHub
karan1205
/
javascript-things
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
24
Code
Issues
0
Pull requests
9
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
javascript-things
/
DesignPatterns
/
ModulePattern
/
index.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (23 loc) · 553 Bytes
Breadcrumbs
javascript-things
/
DesignPatterns
/
ModulePattern
/
index.js
Copy path
File metadata and controls
32 lines (23 loc) · 553 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Module Pattern
*/
const
basketModule
=
(
function
(
)
{
// Privates
const
basket
=
[
]
;
const
doSomethingPrivate
=
function
(
)
{
}
;
// Return an object exposed to the public
return
{
addItem
:
function
(
item
)
{
basket
.
push
(
item
)
;
}
,
getItemCount
:
function
(
)
{
return
basket
.
length
;
}
,
doSomething
:
doSomethingPrivate
}
}
)
(
)
;
basketModule
.
addItem
(
{
item
:
'sugar'
,
price
:
100
}
)
;
console
.
log
(
basketModule
.
getItemCount
(
)
,
'count'
)
;
Back
|
FazBrowse Home
|
New Git URL