JavaScript - The ternary operator

JavaScript - The ternary operator

The ternary operator is a simplified conditional operator like if / else.

Syntax: condition ? <expression if true> : <expression if false>

Here is an example using if / else:

Before

if (isAuthenticated) {
   renderApp();
} else {
   renderLogin();
}

After

isAuthenticated ? renderApp() : renderLogin()