Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Meaning

Status
Not open for further replies.

extempore

Programmer
Jun 1, 2001
71
US
What does this statement mean?

int newSize = size>10?10:size;

Can comeone tell me please. Thanks
 
For which version of javascript are you writing this application? I'm not familiar with "int" being a valid javascript keyword.

Anyways, the statement means:

Create a (n integer) variable called "newSize". If the value stored in the variable "size" is greater than 10 THEN store in "newSize" value 10. OTHERWISE (ELSE) store in "newSize" the value that is currently stored in "size".

It is a shortcut for the following code snippet:

if(size>10)
{
int newSize = 10
}
else
{
int newSize = size
}

Note well, I'm not sure what this "int" business is all about.

jared@eae.net -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top