|
| 06 Aug 2012 12:26 PM |
When you do
function Pet(name,size,color,type){ this.type = type; this.size = size; this.color = color; this.type = type; }
What is happening when you do this.type = type? |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2012 12:30 PM |
It is setting the object's argument "type" as the variable defined in the local code before that. For instance:
type = "dog"; size = "medium-large"; color = "brown"; name = "Spot"
function Pet(name,size,color,type){ this.name = name; // I think this is what you meant. this.size = size; this.color = color; this.type = type; }
This would return:
>function pet >>name: Spot >>size: medium-large >>color: brown >>type: dog |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2012 12:50 PM |
| So it's just saving property's? |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2012 12:51 PM |
Short answer: Yes.
Long answer: "Saving" is a bit of a vague word. It is more of setting the properties into the function. |
|
|
| Report Abuse |
|
|