JavaScript Conditional Operator

JavaScript Conditional operator is as same as if condition,here if condition inside the parenthesis first value is been assigned to variable otherwise second value.

JavaScript Conditional Operator Syntax:

variablename= (condition) ? value1 value2

JavaScript Conditional Operator Examples:

var Gender= (isMale) ? true : false;

var length=(strVar.lenght > 0) ? strVar : ‘Value not avilable’;

 

Leave a Reply