Created
June 5, 2013 02:58
-
-
Save ashanbh/5711315 to your computer and use it in GitHub Desktop.
JQuery NameSpace Declaration
This file contains 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
(function(nameSpace) { | |
//Private Property | |
var myPrivateProperty = true; | |
//Private Method | |
function doSomething( item ) { | |
if ( item !== undefined ) { | |
console.log( "Adding " + $.trim(item) ); | |
} | |
} | |
//Public Property | |
nameSpace.ingredient = "Bacon Strips"; | |
//Public Method | |
nameSpace.sayHello = function() { | |
doSomething(); | |
console.log( "Hello " ); | |
}; | |
}( window.MyNameSpace = window.MyNameSpace || {})); | |
//Adding New Functionality to the NameSpace | |
(function( nameSpace) { | |
//Public Method | |
nameSpace.toString = function() { | |
console.log( myPrivateProperty ); | |
}; | |
}( window.MyNameSpace = window.MyNameSpace || {})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment