The Ternary operator replaces an if/then block in a very small compact way. It’s mostly used in one liners for simple tests and replacements, like this:
var x = false; var s = x ? "yes" : "no"; console.log(s); //→ "no"
If condition is true, the operator returns the value of expr1; otherwise, it returns the value of expr2. For example, to display a different message based on the value of the isMember variable, you could use this statement:
Read more: MDN