chattes
5/20/2016 - 8:36 AM

Visibility.js

//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());