+ 1
What is a meaning of '?' In javascript?
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
+ 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?
+ 1
thanks but still Iam not getting .