<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-a-ternary-operator-is-not-a-conditional-operator-in-js-zaxpay8bs" -->

---
title: Why a Ternary Operator is not a Conditional Operator in JS
description: Until recently, I called a ternary operator a conditional operator in JavaScript. But I just learned that this isn't correct. In this tutorial, I will explain...
canonical: https://daily.dev/posts/why-a-ternary-operator-is-not-a-conditional-operator-in-js-zaxpay8bs
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why a Ternary Operator is not a Conditional Operator in JS | daily.dev
og:description: Until recently, I called a ternary operator a conditional operator in JavaScript. But I just learned that this isn't correct. In this tutorial, I will explain...
og:url: https://daily.dev/posts/why-a-ternary-operator-is-not-a-conditional-operator-in-js-zaxpay8bs
og:image: https://api.daily.dev/og/posts/zAxPaY8BS.png
og:image:alt: Why a Ternary Operator is not a Conditional Operator in JS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why a Ternary Operator is not a Conditional Operator in JS

**[freeCodeCamp](https://daily.dev/sources/freecodecamp)** · [@dillionmegida](https://daily.dev/dillionmegida) · 3 min read · 76 upvotes · 6 comments

## Summary

Until recently, I called a ternary operator a conditional operator in JavaScript. But I just learned that this isn't correct. In this tutorial, I will explain how I learned this, and hopefully it teaches you something new. I have a video version on this topic you can watch as well to supplement your learning.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.freecodecamp.org/news/why-a-ternary-operator-is-not-a-conditional-operator-in-js/>

## Community discussion

Top comments from developers on daily.dev.

**@ghost** · 4 upvotes

> Great article, it is really helpful to understand the difference between a ternary operator and a conditional operator. I appreciated how this article also mentioned that the confusion comes from the fact that the conditional operator is the only ternary operator in JavaScript, but in other languages there could be more examples of the ternary operator. Thanks for sharing.

**@betweennames** · 3 upvotes

> I've literally never thought about this before, and it makes so much sense. It's always confused me why this concept has been called the "3 operator" everywhere
>
> C# and JS are the two primary places I've seen it, but now looking at the C# docs they're very clear that is not it's name.. this is crazy!
>
> https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-operator)
>
> >The conditional operator `?:`, also known as the ternary conditional operator

**@ishaan\_codes** · 1 upvotes

> Elaborative enough.

**@dvmstzzy** · 0 upvotes

> anyone can suggest me a web to learn js?

**@aryanbabber** · 0 upvotes

> Good one!!

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/why-a-ternary-operator-is-not-a-conditional-operator-in-js-zaxpay8bs)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Why a Ternary Operator is not a Conditional Operator in JS","url":"https://daily.dev/posts/why-a-ternary-operator-is-not-a-conditional-operator-in-js-zaxpay8bs","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-a-ternary-operator-is-not-a-conditional-operator-in-js-zaxpay8bs"},"datePublished":"2023-01-17T18:55:15.833Z","dateModified":"2023-01-17T18:55:15.754Z","description":"Until recently, I called a ternary operator a conditional operator in JavaScript. But I just learned that this isn't correct. In this tutorial, I will explain...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eef57aa1b7662004ee3066b54726339b","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eef57aa1b7662004ee3066b54726339b","isAccessibleForFree":true,"articleSection":"freeCodeCamp","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Dillion Megida","url":"https://daily.dev/dillionmegida","image":"https://lh3.googleusercontent.com/a-/AOh14GhsdJDVct4Ey9D1H1iIIksJ7CSThh8JBubqfjbp4lM=s100","description":"Developer Advocate and Content Creator passionate about simplifying tech via videos and articles and also sharing my life and career experiences.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":450}},"commentCount":6,"discussionUrl":"https://daily.dev/posts/why-a-ternary-operator-is-not-a-conditional-operator-in-js-zaxpay8bs","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":76},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":6}],"keywords":"javascript","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"freeCodeCamp","item":"https://daily.dev/sources/freecodecamp"},{"@type":"ListItem","position":3,"name":"Why a Ternary Operator is not a Conditional Operator in JS"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/why-a-ternary-operator-is-not-a-conditional-operator-in-js-zaxpay8bs","comment":[{"@type":"Comment","text":"Great article, it is really helpful to understand the difference between a ternary operator and a conditional operator. I appreciated how this article also mentioned that the confusion comes from the fact that the conditional operator is the only ternary operator in JavaScript, but in other languages there could be more examples of the ternary operator. Thanks for sharing.","datePublished":"2023-01-18T21:31:00.295Z","url":"https://daily.dev/posts/zAxPaY8BS#c-E7Xn3coc8","author":{"@type":"Person","name":"Deleted user","url":"https://daily.dev/ghost","image":"https://media.daily.dev/image/upload/s--hNIUzLiO--/f_auto/v1705327420/public/ghost_vlftth"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4}},{"@type":"Comment","text":"I’ve literally never thought about this before, and it makes so much sense. It’s always confused me why this concept has been called the “3 operator” everywhere\nC# and JS are the two primary places I’ve seen it, but now looking at the C# docs they’re very clear that is not it’s name… this is crazy!\nhttps://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-operator)\n\nThe conditional operator ?:, also known as the ternary conditional operator","datePublished":"2023-01-18T22:53:38.164Z","url":"https://daily.dev/posts/zAxPaY8BS#c-qK7VKPszH","author":{"@type":"Person","name":"Kenneth Hoff","url":"https://daily.dev/betweennames","image":"https://avatars.githubusercontent.com/u/17124533?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"Elaborative enough.","datePublished":"2023-01-19T06:37:13.579Z","url":"https://daily.dev/posts/zAxPaY8BS#c-zCMy5ksPd","author":{"@type":"Person","name":"Ask Ishaan Codes","url":"https://daily.dev/ishaan_codes","image":"https://lh3.googleusercontent.com/a-/AOh14GhsODH_g9GTRv226q2hEvebAMvw7ZLIM82clpqukQ=s100"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"anyone can suggest me a web to learn js?","datePublished":"2023-01-22T11:49:06.576Z","url":"https://daily.dev/posts/zAxPaY8BS#c-TPpK2UAJO","author":{"@type":"Person","name":"Dani Vicky Mahenda","url":"https://daily.dev/dvmstzzy","image":"https://lh3.googleusercontent.com/a/AEdFTp4FcP-Zb2RytpZv0IJHzrtI-74nmHwwtzIaZeZWfA=s96-c"}},{"@type":"Comment","text":"Good one!!","datePublished":"2023-01-24T11:37:40.270Z","url":"https://daily.dev/posts/zAxPaY8BS#c-OB9BGp6nH","author":{"@type":"Person","name":"Aryan Babber","url":"https://daily.dev/aryanbabber","image":"https://avatars.githubusercontent.com/u/86878236?v=4"}}]}
```

