Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Unsere Freiwilligen haben diesen Artikel noch nicht in Deutsch übersetzt. Machen Sie mit und helfen Sie, das zu erledigen!

In computer science, a boolean is a logical data type that can have only the values true or false. A boolean is how a programming language lets you represent true and false. Without the ability to represent the boolean values a number of things in a language would no longer work. For example, in JavaScript, an if statement's conditional has to resolve to a boolean value for it to execute at all.  In a JavaScript for loop without it's boolean conditional the loop would never know whether to run it's coding or not. 

***JavaScript if Statement***
if(boolean conditional) {
   //coding
}

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



***JavaScript for Loop***
for(control variable; boolean conditional; counter) {
  //coding
}

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

 

 

Learn more

General knowledge

Technical reference

Schlagwörter des Dokuments und Mitwirkende

 Zuletzt aktualisiert von: rajkishor09,