JavaScript Conditional Operator

You are Here:

JavaScript Conditional Operator

The conditional operator executes the condition and returns a boolean value. If the boolean value is true, then the first expression will be executed. Otherwise, the second expression will be executed.

The conditional operator is also called as ternary operator.

The conditional (ternary) operator is the only JavaScript operator that takes three operands.


HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var mark = 35; var result = (mark < 50) ? "Fail":"Pass"; document.write(result); </script> </body> </html>


(condition) ? Expression1:Expression2

Parameter Values

conditionRequiredAn expression whose value is used as a condition.


Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author