Truthy

In programming, a value is considered “truthy” if it is evaluated as true in a boolean context. This concept is not limited to a specific programming language and is found in various languages, including JavaScript.

In JavaScript, truthy values are those that coerce to true when evaluated as a boolean. This includes values like non-empty strings, numbers other than zero, objects, arrays, and functions. While the concept of truthy values exists in many programming languages, the specific values considered truthy may vary.

Example: Here are some examples of truthy values in JavaScript:

if (1) {
    console.log('1 is truthy'); // Output: '1 is truthy'
}

if ('hello') {
    console.log('hello is truthy'); // Output: 'hello is truthy'
}

if ({}) {
    console.log('{} is truthy'); // Output: '{} is truthy'
}