Triple operator:
A ternary operator represented by a name requires three operands.
Is syntax a condition? Result 1: Result 2;. Here you write the condition before the question mark (?) and then the result 1 and result 2 separated by a colon (:). Result 1 if the condition is met, otherwise the result will be 2.
<script type="text/javascript"> var b=5; (b == 5) ? a="true" : a="false"; document.write(" -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Results: ------------------------------------------------------------------------------------------------------------------------------
<script type="text/javascript"> var b=true; (b == false) ? a="true" : a="false"; document.write(" -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Results: ------------------------------------------------------------------------------------------------------------------------------
The above is the full understanding of the javascript ternary operator brought to you by the editor. I hope everyone can support Wulin.com more~