-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodules.html
47 lines (36 loc) · 943 Bytes
/
modules.html
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<html>
<head>
<script>
var Exposer = (function() {
var privateVariable = 10;
var publicVariable = 20;
var privateMethod = function() {
console.log('Inside a private method!');
privateVariable++;
}
var methodToExpose = function() {
console.log('This is a method I want to expose!');
}
var otherMethodIWantToExpose = function() {
privateMethod();
}
var methodWithParamters = function (a,b) {
console.log(a + ' ' + b);
}
return {
first: methodToExpose,
second: otherMethodIWantToExpose,
third: methodWithParamters,
publicVariable
};
})();
Exposer.first(); // Output: This is a method I want to expose!
Exposer.second(); // Output: Inside a private method!
Exposer.methodToExpose; // undefined
Exposer.third("Hello", "World"); // Method accepting paramters
console.log(Exposer.publicVariable); // Printing public variable
</script>
</head>
<body>
</body>
</html>