Boolean

In computer science, a Boolean is a logical data type that can have only the values true or false.

For example, in JavaScript, Boolean conditionals are often used to decide which sections of code to execute (such as in if statements) or repeat (such as in for loops).

Below is some JavaScript pseudocode (it's not truly executable code) demonstrating this concept.

js
/* JavaScript if statement */
if (boolean conditional) {
  // code to execute if the conditional is true
}

if (boolean conditional) {
  console.log("boolean conditional resolved to true");
} else {
  console.log("boolean conditional resolved to false");
}

/* JavaScript for loop */
for (control variable; boolean conditional; counter) {
  // code to execute repeatedly if the conditional is true
}

The Boolean value is named after English mathematician George Boole, who pioneered the field of mathematical logic.

Above is a general introduction. The term Boolean can have more specific meanings depending on the context. It may refer to:

Boolean (JavaScript)
A Boolean in JavaScript is a Primitive that can be either true or false.
Boolean attribute (ARIA)
A boolean attribute in ARIA is an Enumerated that includes true or false in the enumerated list.
Boolean attribute (HTML)
A boolean attribute in HTML is an attribute that represents true or false values. If an HTML tag contains a boolean attribute — no matter the value of that attribute — the attribute is set to true on that element. If an HTML tag does not contain the attribute, the attribute is set to false.

See also