-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 Module Pattern > Module Pattern > add
- Loading branch information
Showing
4 changed files
with
103 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,11 +51,6 @@ $(document).ready(function () { | |
} | ||
}).catch(error => ui.AlertInfo(info)) | ||
} | ||
|
||
}) | ||
|
||
|
||
|
||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
|
||
<script src="../JS/77_18_1_JsModul.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
//! 1) Global variable naming conflicts | ||
|
||
|
||
// scrip.js | ||
// var name = "Eli" | ||
|
||
|
||
// app.js | ||
// var name = "Ehmed" | ||
|
||
|
||
// console.log(name) | ||
|
||
var ehmed = (function(){ | ||
var names = "Ehmed" | ||
console.log(names) | ||
})() | ||
|
||
|
||
|
||
var cebil = (function(){ | ||
var names = "cebil" | ||
console.log(names) | ||
})() | ||
|
||
// console.log(names) | ||
|
||
|
||
|
||
//! 2) Encapsulation | ||
|
||
var Counter = { | ||
number:0, | ||
increment:function(){ | ||
return ++this.number | ||
}, | ||
decrement:function(){ | ||
return --this.number | ||
} | ||
|
||
} | ||
|
||
// console.log(Counter.increment()) | ||
// console.log(Counter.increment()) | ||
// console.log(Counter.decrement()) | ||
// Counter.number=10// This is problem | ||
// console.log(Counter.decrement()) | ||
|
||
|
||
let Module = (function(){ | ||
var number = 5 | ||
function Increment(){ | ||
return ++number | ||
} | ||
|
||
function Decrement(){ | ||
return --number | ||
} | ||
|
||
|
||
return{ | ||
Increment,Decrement | ||
} | ||
|
||
})() | ||
|
||
// console.log(number) | ||
// console.log(Module.number) | ||
console.log(Module.Increment()) | ||
console.log(Module.Increment()) | ||
console.log(Module.Decrement()) | ||
|
||
let Mod = (function(){ | ||
|
||
let privateMethod = function(){ | ||
// some amazing code | ||
} | ||
|
||
|
||
return { | ||
publicMethod : function(){ | ||
return 'amazing' | ||
} | ||
} | ||
})() | ||
|
||
console.log(Mod.publicMethod()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## JavaScript Module | ||
> Istənilən `app` da biz həmin `app` yazılamsı zaman sadələşdırməyə getməyə çalışırıq. Bu münasibətə əsasən məsələni daha da asanlaşdırmaq üçün `app` modullara bölərək `app`in icrasını həmin modullar vastəsi ilə həyata keçirə bilərik. Bu bizə onu daha yaxşı icrata keçirməyə imkan veririr və gələcəkdə ola biləcək gəliştirmələr zamanı bütün `app`i deyildə sadəcə bir modul üzərində dəişiklik edərək həmin gəliştirməni irəllədə bilərik. |