Overview

Boolean algebra is the branch of algebra that deals with inputs of 0 or 1 and uses formulas to return a result.

Logic

The AND operation or also known as conjunctive takes two inputs and returns true only if both inputs are 1.

//x and y are inputs, x AND y
var thisResultIsTrueAfterUsingAND = true && true;

The OR operation, also known as disjunctive takes two inputs and returns true if at least one of the inputs are 1.

var thisResultIsTrueAfterUsingOR = true || false; 

The NOT operation or negation takes an input and returns the opposite of the value.

var thisResultIsFalseAfterUsingNOT = !true;
var thisResultIsTrueAfterUsingNOT = !false;

Conclusion

Every programming language uses Boolean algebra to handle logic for use cases. If you practice the code examples in this article you will become very proficient and have the ability to learn new languages quicker.

Leave a Reply