Skip to content

Instantly share code, notes, and snippets.

@rjoydip-zz
Last active February 24, 2017 05:40
Show Gist options
  • Save rjoydip-zz/64692f1f9fe0ebb80a19021012511f79 to your computer and use it in GitHub Desktop.
Save rjoydip-zz/64692f1f9fe0ebb80a19021012511f79 to your computer and use it in GitHub Desktop.
This is the basic library structure (it is following modular pattern)
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