{"id":5108,"date":"2023-05-13T01:13:00","date_gmt":"2023-05-13T06:13:00","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=5108"},"modified":"2023-05-13T00:53:18","modified_gmt":"2023-05-13T05:53:18","slug":"javascript-ternary-operator","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/javascript-ternary-operator\/","title":{"rendered":"Javascript Ternary Operator"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>The ternary operator is a conditional operator that takes three (ternary) options. We can almost think of it as a concise if then statement.<\/p>\n\n\n\n<p>The basic syntax is as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\" line-numbers\">Condition ? Value-If-True : Value-If-False<\/code><\/pre>\n\n\n\n<p>For an example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\" line-numbers\">const isOver21 = age >= 21 ? \"Is over 21\" : \"Is Under 21\"<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Expressions_and_Operators#conditional_ternary_operator\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Expressions_and_Operators#conditional_ternary_operator<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ternary operator is a conditional operator that takes three (ternary) options. We can almost think of it as a concise if then statement. The basic syntax is as follows. For an example https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Expressions_and_Operators#conditional_ternary_operator<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[792],"tags":[1437,1499],"class_list":["post-5108","post","type-post","status-publish","format-standard","hentry","category-programming","tag-javascript","tag-ternary"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=5108"}],"version-history":[{"count":15,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5108\/revisions"}],"predecessor-version":[{"id":5126,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5108\/revisions\/5126"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=5108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=5108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=5108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}