Vacuous Truth in JS

August 22, 2025

What we will learn in this blog

  1. JavaScript's every array method

  2. Root in discrete mathematics

  3. What does it mean to be vacuous?

Just the other day, I was testing a permissions function when I came across something interesting about Array.prototype.every. Let me give you a little backstory. The function I was testing is a simple one that checks whether a user has the permissions required to access a given module or perform an action. This function happened to use the JavaScript array method every.

The way every works is that it loops through an array and checks whether all items satisfy a provided condition. If it encounters an item that doesn’t, it breaks the loop and returns false. If all items satisfy the condition, it returns true. However, there’s a peculiar behavior with this method: if the array is empty, it still returns true. This is where the concept of vacuous truth comes in.

const arr1 = [2, 4, 7, 8, 10] const arr2 = [2, 4, 6, 8, 10] const arr3 = [] const checkIfAllAreEven = (items: number[]) => { return items.every((item)=> item % 2 === 0) }

let allAreEven = checkIfAllAreEven(arr1) console.log(allAreEven) // logs false allAreEven = checkIfAllAreEven(arr2) console.log(allAreEven) // logs true allAreEven = checkIfAllAreEven(arr3) console.log(allAreEven) // logs true

The concept of vacuous truth took me back to my university days, when I studied mathematics and was fascinated by discrete math. I never imagined that this rabbit hole I stumbled into would reignite my interest in the subject.

So, what exactly are vacuous truths? A vacuous truth is a conditional statement with a false antecedent. When the antecedent is false, we cannot infer anything about the consequent’s truth value. A statement is also considered vacuous if the subject of the statement doesn’t exist.

When using the every method, the logical statement being tested is “all items satisfy a given condition.” In the example above, we want to check whether all numbers are even—but since there are no numbers in arr3, the statement is vacuously true.

  • All
  • JavaScript

Vacuous Truth in JS

August 22, 2025

What we will learn in this blog

  1. JavaScript's every array method

  2. Root in discrete mathematics

  3. What does it mean to be vacuous?

Just the other day, I was testing a permissions function when I came across something interesting about Array.prototype.every. Let me give you a little backstory. The function I was testing is a simple one that checks whether a user has the permissions required to access a given module or perform an action. This function happened to use the JavaScript array method every.

The way every works is that it loops through an array and checks whether all items satisfy a provided condition. If it encounters an item that doesn’t, it breaks the loop and returns false. If all items satisfy the condition, it returns true. However, there’s a peculiar behavior with this method: if the array is empty, it still returns true. This is where the concept of vacuous truth comes in.

const arr1 = [2, 4, 7, 8, 10] const arr2 = [2, 4, 6, 8, 10] const arr3 = [] const checkIfAllAreEven = (items: number[]) => { return items.every((item)=> item % 2 === 0) }

let allAreEven = checkIfAllAreEven(arr1) console.log(allAreEven) // logs false allAreEven = checkIfAllAreEven(arr2) console.log(allAreEven) // logs true allAreEven = checkIfAllAreEven(arr3) console.log(allAreEven) // logs true

The concept of vacuous truth took me back to my university days, when I studied mathematics and was fascinated by discrete math. I never imagined that this rabbit hole I stumbled into would reignite my interest in the subject.

So, what exactly are vacuous truths? A vacuous truth is a conditional statement with a false antecedent. When the antecedent is false, we cannot infer anything about the consequent’s truth value. A statement is also considered vacuous if the subject of the statement doesn’t exist.

When using the every method, the logical statement being tested is “all items satisfy a given condition.” In the example above, we want to check whether all numbers are even—but since there are no numbers in arr3, the statement is vacuously true.

  • All
  • JavaScript