Skip to content

Instantly share code, notes, and snippets.

@pertrai1
Created January 7, 2015 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pertrai1/9d447e724299fe29b4d0 to your computer and use it in GitHub Desktop.
Save pertrai1/9d447e724299fe29b4d0 to your computer and use it in GitHub Desktop.
JS Conversation Example
//COMPILER: Engine, do you have an Animal and a dog available?
//ENGINE: Yes, I have both of those available
var Animal, dog;
//COMPILER: Engine, I see a function with no name and parameter named inLove.
//ENGINE: I don't have that so I will assign to Animal so Animal can reference
//this anonmyous function
//COMPILER: Scope, do you have a parameter lovesHumans?
//SCOPE: Yes, I do, and I have it reference inLove. If inLove is not passed as a
//value, then lovesHumans will be false
Animal = function(inLove) {
this.lovesHumans = inLove || false;
};
//COMPILER: I am going to create a new object based off of the dog variable that
//is constructed by the Animal object. I see that true has been passed in as a
//variable for inLove so I will set loveHumans to true, in another words
//dog.lovesHumans = true;
dog = new Animal(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment