MDN wants to learn about developers like you:

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).

/* 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

for (var i=0; i < 4; i++) {
  console.log("I print only when the boolean conditional is true");

Learn more

General knowledge

Technical reference

Document Tags and Contributors

 Last updated by: mansil,