+ 1

What is a meaning of '?' In javascript?

15th Jun 2017, 9:15 AM
MILIND JAIN
MILIND JAIN - avatar
3 ответов
+ 8
Conditional operator :3 alert ( 3 > 5 ? 3 : 5 ) You can see the above statement as: if ( 3 > 5 ) alert ( 3 ) else alert ( 5 ) So, condition operator checks a statement and give the result in this way: condition ? true : false
15th Jun 2017, 9:21 AM
Maz
Maz - avatar
+ 5
It checks the condition used before it. (whether true or false) ~Following Maz's example: •(3 > 5 ?) will check if 3 is greater than 5. since 3 is not greater than 5, the output will be 'false'. •var Number = (3 > 5 ? "3 is greater than 5" : "3 is not greater than 5" ); When the variable "Number" is used, it will check if 3 is greater than 5. If 3 is greater, then Number = "3 is greater than 5". Else Number = "3 is not greater than 5". Do you get it now?
15th Jun 2017, 10:36 AM
Leigh E. O.
Leigh E. O. - avatar
+ 1
thanks but still Iam not getting .
15th Jun 2017, 9:22 AM
MILIND JAIN
MILIND JAIN - avatar