@manhng

Welcome to my blog!

Javascript Module Pattern

July 14, 2017 08:08

Prototype Pattern:

http://scotch.io/amp/bar-talk/4-javascript-design-patterns-you-should-know/

 

var Exposer = (function() {
var privateVariable = 10;

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();
}

return {
first: methodToExpose,
second: otherMethodIWantToExpose
};
})();

Exposer.first(); // Output: This is a method I want to expose!
Exposer.second(); // Output: Inside a private method!
Exposer.methodToExpose; // undefined

Module JavaScript

July 5, 2017 17:37

Module Javascript: Hướng dẫn cho người mới

https://viblo.asia/p/module-javascript-huong-dan-cho-nguoi-moi-OeVKBgVMZkW

Module Javascript phần 2: Đóng gói module

https://viblo.asia/p/module-javascript-phan-2-dong-goi-module-GrLZDVve5k0

 

Categories

Recent posts