Created
January 23, 2012 07:39
-
-
Save FiNGAHOLiC/1661418 to your computer and use it in GitHub Desktop.
JS Coding Style
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
| // http://dev.opera.com/articles/view/javascript-best-practices/ | |
| // Using some globals | |
| var current = null; | |
| var init = function(){}; | |
| var change = function(){}; | |
| var verify = function(){}; | |
| // Using object literal | |
| var myNameSpace = { | |
| current : null, | |
| init : function(), | |
| change : function(){}, | |
| verify : function(){} | |
| }; | |
| // Module pattern | |
| var myNameSpace = function(){ | |
| var current = null; | |
| var init = function(){}; | |
| var change = function(){}; | |
| var verify = function(){}; | |
| }; | |
| // Module pattern | |
| var MyNameSpace = function(){ | |
| var current = null; | |
| var verify = function(){}; | |
| return{ | |
| init : function(){}, | |
| change : function(){} | |
| }; | |
| }; | |
| // Module pattern | |
| var MyNameSpace = function(){ | |
| var current = null; | |
| var init = function(){}; | |
| var change = function(){}; | |
| var verify = function(){}; | |
| return{ | |
| init : init, | |
| change : change | |
| }; | |
| }; | |
| // Module pattern | |
| var MyNameSpace = function(){ | |
| var current = null; | |
| var init = function(){}; | |
| var change = function(){}; | |
| var verify = function(){}; | |
| return{ | |
| init : init, | |
| set : change | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment