Created
January 7, 2015 18:17
-
-
Save pertrai1/9d447e724299fe29b4d0 to your computer and use it in GitHub Desktop.
JS Conversation Example
This file contains 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
//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