Lably
Skip to content

Truth value

Value indicating the relation of a proposition to truth

  • 3 min read
  • 5 chapters

Related on Lably

Through Logic, Mathematics and Proposition

Computing

In some programming languages, any expression can be evaluated in a context that expects a Boolean data type. Typically (though this varies by programming language) expressions like the number zero, the empty string, empty lists, and null are treated as false, and strings with content (like "abc"), other numbers, and objects evaluate to true. Sometimes these classes of expressions are called falsy and truthy. For example, in Lisp, nil, the empty list, is treated as false, and all other values are treated as true. In C, the number 0 or 0.0 is false, and all other values are treated as true.

In JavaScript, the empty string (""), null, undefined, NaN, +0, −0 and false are sometimes called falsy (of which the complement is truthy) to distinguish between strictly type-checked and coerced Booleans (see also: JavaScript syntax#Type conversion). As opposed to Python, empty containers (arrays, maps, sets) are considered truthy. Languages such as PHP also use this approach.

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Philosophy