Created
May 20, 2016 08:36
-
-
Save chattes/2c73ec15de6c4a6216aebb764f9ace6c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//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