truthy
- adjective
- /ˈtruːθi/
- Specialized
- 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
Surface Forms
Morphology
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.