Skip to main content
truthy

truthy

9.1
A value that counts as yes in an if statement
  • adjective
  • /ˈtruːθi/
  • Specialized
translation icon : verdadero
  • Empty strings are not truthy in most programming languages.

Examples

  • You should check if the variable is truthy before using it in your code.

  • In JavaScript, any non-zero number is considered truthy.

  • In JavaScript, the number 1 is considered truthy in conditional statements.

  • The string 'hello' is truthy in many programming languages.

  • In programming, a non-empty string is considered truthy and will evaluate as true in a condition.

  • If a variable contains a number greater than zero, it is treated as truthy in the boolean context.

  • The boolean expression will return true because the provided input is truthy instead of false.

Compounds

truthy statement
  • Literature
8.3

A statement that sounds believable but may not be real

Surface Forms

truthy positive

Morphology

truthy = truth (semi-transparent) = truth + y

Formed by the productive suffix -y on 'truth', but the programming sense is a specialized extension ('evaluates as true') that may not be obvious to general learners.

Etymology

Truthy is made from truth and the ending -y, which means 'like' or 'having' that quality. Programmers started using this word to name values that a computer treats 'as true' when it checks them. So a truthy value is one that behaves 'as true' in code.