Last active
February 24, 2017 05:40
-
-
Save rjoydip-zz/64692f1f9fe0ebb80a19021012511f79 to your computer and use it in GitHub Desktop.
This is the basic library structure (it is following modular pattern)
This file contains hidden or 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
var RjLib = (function RjLib() { | |
var _helloText = 'Hello world'; | |
/* | |
** This constructor can be annoynomus | |
** or it can have function name | |
*/ | |
// Return the constructor | |
return function(){ | |
var _this = this; // Cache the `this` keyword | |
// returning public function | |
_this.hello = hello; | |
}; | |
function hello() { | |
return _helloText; // Access a private variable | |
} | |
}()); | |
var myLib = new RjLib(); // invoke |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment