ternary operator condition set in javascript code example
Example 1: ternary function javascript
var variable;
if (condition)
variable = "something";
else
variable = "something else";
//is the same as:
var variable = condition ? "something" : "something else";
Example 2: ternary operator js
condition ? expression1 : expression2
// Will return expression1 if condition = true and expression2 if condition != true