Created
April 27, 2014 07:07
-
-
Save svapreddy/11339370 to your computer and use it in GitHub Desktop.
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
// Author : Prathap Reddy SV | |
// Purpose : Show an Example of the code structure I use. | |
var Example = (function($, document, window, undef){ | |
// Bake your Object inside. | |
function Example(a, b){ | |
this.a = a === undef ? 0 : a; | |
this.b = b === undef ? 0 : b; | |
} | |
// Private | |
function examplePrivate(a){ | |
return a; | |
} | |
// Public | |
Example.prototype.method1 = function(){ | |
var that = this; | |
return examplePrivate(that.a); | |
} | |
Example.prototype.method2 = function(){ | |
// Do something | |
} | |
return Example; | |
})(window.jQuery || window.Zepto, document, window); | |
// Then initialize like below | |
var ex1 = new Example(10, 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment