Ajax Loader
×

Javascript Conditional (Ternary) Operator

The conditional (or ternary) operator is a special Javascript operator that can be used as a shorthand for if..else statement. It is the only operator that takes 3 operands.

It's syntax is like this:
condition ? val1 : val2

If the condition expression evaluates to true then the operator returns val1 else the entire expression evaluates to val2.

val1 and val2 can be replaced with yet another conditional expression resulting into nested conditional operators.

Related:


    Warning: Invalid argument supplied for foreach() in /var/www/cssdeck.com/app/modules/labs/views/_details.php on line 68
×

Coding Preferences


HTML

CSS

Javascript

More

×

Your Default Settings - Preferences

×
×
×

Validations

(Errors from your JS or Pre-Processors code)

    HTML
    CSS
    JavaScript

    Javascript Conditional (Ternary) Operator

    CSSDeck G+