Data Types

Boolean

🙋 Need help? Ask an expert now!

Boolean has two possible values, true or false. Boolean is one of the most useful data types as you will be using it for almost everything, from control flow statements to loops and much more. Booleans are often evaluated through expressions with operators such as '=' and '>'. The sample code below shows different examples of boolean expressions.

The variable greaterAB holds false because 1 is not greater than 2. The variable equalA1 will be true because the variable a is holding the integer value of 1. The examples above are very simple examples of how booleans are used in JavaScript. However, statements like these are what we need to build functional programs or sites in the future, so make sure you understand why the expressions evaluate to true and false respectively.

Edit Me on GitHub!

Application Question

Which of the following statements result in true?