{"id":70,"date":"2026-05-01T13:40:28","date_gmt":"2026-05-01T13:40:28","guid":{"rendered":"https:\/\/gigz.pk\/javascript\/?post_type=lesson&#038;p=70"},"modified":"2026-05-01T13:40:29","modified_gmt":"2026-05-01T13:40:29","slug":"booleans","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/javascript\/?lesson=booleans","title":{"rendered":"Booleans"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Booleans are one of the most basic and important data types in JavaScript. They represent logical values and are used to control decision making in programs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Introduction<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A Boolean can have only two values: true or false. These values help determine the flow of a program based on conditions. Booleans are commonly used in comparisons, conditions, and loops.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Core Purpose of Booleans<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Booleans help developers make decisions in code<br>They control the execution of conditions<br>They are used in comparisons and logical operations<br>They help manage application logic efficiently<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Boolean Values<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">true means yes, correct, or enabled<br>false means no, incorrect, or disabled<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Using Booleans in JavaScript<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Booleans are often created through comparisons<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>let isLoggedIn = true;<br>let isAdmin = false;<br><br>let result = 10 &gt; 5; \/\/ true<br>let check = 7 === 3; \/\/ false<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Comparison Operators<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Equal to checks if values are the same<br>Strict equal checks value and type<br>Not equal checks if values are different<br>Greater than and less than compare numbers<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>console.log(5 &gt; 3);   \/\/ true<br>console.log(5 &lt; 3);   \/\/ false<br>console.log(5 == \"5\");  \/\/ true<br>console.log(5 === \"5\"); \/\/ false<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Logical Operators<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Logical operators work with Boolean values<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">AND returns true if both conditions are true<br>OR returns true if at least one condition is true<br>NOT reverses the value<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>let a = true;<br>let b = false;<br><br>console.log(a &amp;&amp; b); \/\/ false<br>console.log(a || b); \/\/ true<br>console.log(!a);     \/\/ false<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Booleans in Conditions<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Booleans are widely used in if statements<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>let age = 18;<br><br>if (age &gt;= 18) {<br>  console.log(\"You can vote\");<br>} else {<br>  console.log(\"You cannot vote\");<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Common Use Cases<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Form validation to check user input<br>User authentication systems<br>Feature toggles in applications<br>Loop control and condition handling<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conclusion<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Booleans are essential for controlling logic in JavaScript. Understanding how to use true and false values helps you write smarter and more efficient code.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/javascript\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">JavaScript Fundamentals (Beginner Level) > Variables and Data Types > Booleans<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1777642800572\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1777642800319\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"menu_order":0,"template":"","class_list":["post-70","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Booleans - Learn JavaScript with GIGZ.PK<\/title>\n<meta name=\"description\" content=\"Learn JavaScript Booleans with examples Understand true false values conditions and logical operators for better coding skills\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/javascript\/?lesson=booleans\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Booleans - Learn JavaScript with GIGZ.PK\" \/>\n<meta property=\"og:description\" content=\"Learn JavaScript Booleans with examples Understand true false values conditions and logical operators for better coding skills\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/javascript\/?lesson=booleans\" \/>\n<meta property=\"og:site_name\" content=\"Learn JavaScript with GIGZ.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-01T13:40:29+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=booleans\",\"url\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=booleans\",\"name\":\"Booleans - Learn JavaScript with GIGZ.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/#website\"},\"datePublished\":\"2026-05-01T13:40:28+00:00\",\"dateModified\":\"2026-05-01T13:40:29+00:00\",\"description\":\"Learn JavaScript Booleans with examples Understand true false values conditions and logical operators for better coding skills\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=booleans#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=booleans\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?lesson=booleans#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/javascript\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Fundamentals (Beginner Level) > Variables and Data Types > Booleans\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/\",\"name\":\"Learn JavaScript with GIGZ.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/javascript\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Booleans - Learn JavaScript with GIGZ.PK","description":"Learn JavaScript Booleans with examples Understand true false values conditions and logical operators for better coding skills","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/javascript\/?lesson=booleans","og_locale":"en_US","og_type":"article","og_title":"Booleans - Learn JavaScript with GIGZ.PK","og_description":"Learn JavaScript Booleans with examples Understand true false values conditions and logical operators for better coding skills","og_url":"https:\/\/gigz.pk\/javascript\/?lesson=booleans","og_site_name":"Learn JavaScript with GIGZ.PK","article_modified_time":"2026-05-01T13:40:29+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/javascript\/?lesson=booleans","url":"https:\/\/gigz.pk\/javascript\/?lesson=booleans","name":"Booleans - Learn JavaScript with GIGZ.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/javascript\/#website"},"datePublished":"2026-05-01T13:40:28+00:00","dateModified":"2026-05-01T13:40:29+00:00","description":"Learn JavaScript Booleans with examples Understand true false values conditions and logical operators for better coding skills","breadcrumb":{"@id":"https:\/\/gigz.pk\/javascript\/?lesson=booleans#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/javascript\/?lesson=booleans"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/javascript\/?lesson=booleans#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/javascript"},{"@type":"ListItem","position":2,"name":"JavaScript Fundamentals (Beginner Level) > Variables and Data Types > Booleans"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/javascript\/#website","url":"https:\/\/gigz.pk\/javascript\/","name":"Learn JavaScript with GIGZ.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/javascript\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/lesson\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/javascript\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}