Skip to content

Instantly share code, notes, and snippets.

@chattes
Created May 20, 2016 08:36
Show Gist options
  • Save chattes/2c73ec15de6c4a6216aebb764f9ace6c to your computer and use it in GitHub Desktop.
Save chattes/2c73ec15de6c4a6216aebb764f9ace6c to your computer and use it in GitHub Desktop.
//Controlling Visibility
var Animal = function Animal(init){
var privateInit = init;
var interface = {
getName: function(){
return "init Name: "+privateInit;
},
setName: function(newName){
privateInit = newName;
}
};
return interface;
};
var cat=new Animal("I am cat");
console.log(cat.getName());
cat.setName("Now I am dog");
console.log(cat.getName());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment