<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/what-is-the-difference-between-statement-and-statement-in-javascript--mujf5dyna" -->

---
title: What is the difference between statement and statement...
description: Learn the main difference between if...else and ternary operator in JavaScript. Understand why the ternary operator is considered an expression and if...else...
canonical: https://daily.dev/posts/what-is-the-difference-between-statement-and-statement-in-javascript--mujf5dyna
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: What is the difference between statement and statement in JavaScript? | daily.dev
og:description: Learn the main difference between if...else and ternary operator in JavaScript. Understand why the ternary operator is considered an expression and if...else...
og:url: https://daily.dev/posts/what-is-the-difference-between-statement-and-statement-in-javascript--mujf5dyna
og:image: https://api.daily.dev/og/posts/MuJf5dyna.png
og:image:alt: What is the difference between statement and statement in JavaScript?
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.

# What is the difference between statement and statement in JavaScript?

**[Community Picks](https://daily.dev/sources/community)** · 4 min read · 19 upvotes · 2 comments

## Summary

Learn the main difference between if...else and ternary operator in JavaScript. Understand why the ternary operator is considered an expression and if...else is considered a statement. Discover why if...else cannot be used directly in JSX in a React app.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://kumarshivesh1.hashnode.dev/what-is-the-difference-between-a-statement-and-an-expression-in-javascript>

## Community discussion

Top comments from developers on daily.dev.

**@merix** · 0 upvotes

> Great content!

**@annupkapur** · 0 upvotes

> This is a great article. Well written and clear.

---

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

[View this post on daily.dev](https://daily.dev/posts/what-is-the-difference-between-statement-and-statement-in-javascript--mujf5dyna)

```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":"What is the difference between statement and statement in JavaScript?","url":"https://daily.dev/posts/what-is-the-difference-between-statement-and-statement-in-javascript--mujf5dyna","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/what-is-the-difference-between-statement-and-statement-in-javascript--mujf5dyna"},"datePublished":"2024-04-19T03:16:51.340Z","dateModified":"2024-05-09T09:03:00.647Z","description":"Learn the main difference between if...else and ternary operator in JavaScript. Understand why the ternary operator is considered an expression and if...else...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/302844d26a10a173117152d07c2e121a?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/302844d26a10a173117152d07c2e121a?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"Community Picks","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":"Organization","name":"Community Picks","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1655817725/logos/community","url":"https://daily.dev/sources/community"},"commentCount":2,"discussionUrl":"https://daily.dev/posts/what-is-the-difference-between-statement-and-statement-in-javascript--mujf5dyna","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":19},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"keywords":"javascript,react,jsx","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Community Picks","item":"https://daily.dev/sources/community"},{"@type":"ListItem","position":3,"name":"What is the difference between statement and statement in JavaScript?"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/what-is-the-difference-between-statement-and-statement-in-javascript--mujf5dyna","comment":[{"@type":"Comment","text":"Great content!","datePublished":"2024-04-25T16:40:21.482Z","url":"https://daily.dev/posts/MuJf5dyna#c-GULoLBr4g","author":{"@type":"Person","name":"Merix","url":"https://daily.dev/merix","image":"https://avatars.githubusercontent.com/u/100765780?v=4"}},{"@type":"Comment","text":"This is a great article. Well written and clear.","datePublished":"2024-04-19T08:53:54.207Z","url":"https://daily.dev/posts/MuJf5dyna#c-eCtfwXEkY","author":{"@type":"Person","name":"Annup Kapur","url":"https://daily.dev/annupkapur","image":"https://media.daily.dev/image/upload/s--mO6vWs1M--/f_auto/v1720122484/avatars/avatar_PpYHBxoIvKWcOPuSJuSEd"}}]}
```

