Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
13 lines (10 sloc) 604 Bytes

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"

Description

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

Something went wrong with that request. Please try again.