Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Example 5
(function(){ //opens the closure
//definition of private object Animal
var Animal= function(){"";
getAnimal : function(code){
var s = this;
s.getAnimalCallBackFn = function(response){;
//AJAX call to get the description
url : "getDescription.json",
dataType : "json",
data : JSON.stringify({"code" : code}),
success : s.getAnimalCallBackFn
//myLib public interface
window.myLib = {
selector : null,
initialize : function(){
//public property instantiates an instance of Animal
this.selector= new Animal();
selectAnimal : function(code){
})(); //closes the closure
//initializes selector publicly
//Call selectAnimal publicly
//Returns 'Dog'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment