Created
December 2, 2014 22:00
-
-
Save devdays/c2f4582907d44704a769 to your computer and use it in GitHub Desktop.
Object JavaScript - problem with global var as namespace
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
var myApp= (function(){ | |
// Create a private variable | |
var name = "Bruce"; | |
// Create a private function | |
var greeting = function() { | |
return "Hello " + name; | |
}; | |
// Return an object that exposes our greeting function publicly | |
return { | |
greetings: greeting | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment