Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 2, 2014 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/c2f4582907d44704a769 to your computer and use it in GitHub Desktop.
Save devdays/c2f4582907d44704a769 to your computer and use it in GitHub Desktop.
Object JavaScript - problem with global var as namespace
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