Skip to content

Commit

Permalink
18 Module Pattern > Module Pattern > add
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMadWill committed Jan 4, 2022
1 parent 6b6ce90 commit 99d52cb
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 5 deletions.
5 changes: 0 additions & 5 deletions 17_Acount_Search_App/Js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ $(document).ready(function () {
}
}).catch(error => ui.AlertInfo(info))
}

})




});

13 changes: 13 additions & 0 deletions 18_JavaScript_Modul_Pattern/HTML/will.html
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>
88 changes: 88 additions & 0 deletions 18_JavaScript_Modul_Pattern/JS/77_18_1_JsModul.js
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())
2 changes: 2 additions & 0 deletions Documantation/18_JavaScript_Modul_Pattern/documantation.md
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.

0 comments on commit 99d52cb

Please sign in to comment.