Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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