Explain the Concept of Truthy & Falsy Values in JavaScript ?
Last Updated :
24 Jan, 2024
In JavaScript, truthy and falsy values are concepts related to boolean evaluation. Every value in JavaScript has an inherent boolean “truthiness” or “falsiness,” which means they can be implicitly evaluated to true or false in boolean contexts, such as in conditional statements or logical operations.
Truthy Values: A value is considered truthy if, when coerced to a boolean, it evaluates to true
. Examples of truthy values include non-empty strings, numbers other than 0, arrays, objects, and functions.
Falsy Values: Values that are not true are considered False values. 0, null, undefined, NaN, false(Boolean value), and an empty string (""
).
Share your thoughts in the comments
Please Login to comment...