generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Javascript OOP question.

Previous Thread :: Next Thread 
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
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
teaforapsychopath is not online. teaforapsychopath
Joined: 16 Jul 2012
Total Posts: 412
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
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
06 Aug 2012 12:50 PM
So it's just saving property's?
Report Abuse
teaforapsychopath is not online. teaforapsychopath
Joined: 16 Jul 2012
Total Posts: 412
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image