Archive results for:

JavaScript Tip: Ternary Operator

Using many if or switch statements can make your code very long and complex in no time. A trick to avoid some of the bloating involves using something called the ternary operator.

The ternary operator syntax is:

This is very handy for boolean conditions or very short values. Read more ›