Boolean
<p>We have learned and used all but one last <a href="/courses/video/5/158/What-are-Primitives.html">primitive</a> variable. Are you ready to see it in action? Booleans are simple! They are really only place-holders that can hold only one of two possible values: true or false (0 or 1, yes or no...)</p> <p>Boolean values can be used to state whether a statement is right or wrong. It has only two options: true or false. We may also take this as 0 or 1 if we are using some other programming languages like c and c++. A Boolean value is like a switch which has only two options: on or off.</p> <h2>Assigning and working with Boolean Variables</h2> <p>We can assign a Boolean value to a variable using <b>var a:Boolean = true;</b>. This means the variable is declared as a Boolean value and the option true is assigned to it. We can't assign any other value (such as <a href="/courses/video/4/154/Strings-As-Our-First-Variable.html">string</a> or <a href="/courses/video/4/156/Numbers-As-Our-Second-Variable.html">number</a>) to this Boolean variable other than <b>true</b> or <b>false</b> (0 or 1.) However, if we want to change the Boolean value from true to false later in the program, we can type <b>a= false</b>. This will turn the Boolean value of the <a href="/courses/video/5/157/Using-Variables.html">variable</a> <b>a</b> to <b>false</b>. Remember that these Boolean values (<b>true</b> or <b>false</b>) should be written directly without any double or single quotes.</p>