Binary Logical Operators in JavaScript
JavaScript·1 min read·Jan 1, 2026
In JavaScript, when a non-boolean value is used in a boolean context, for example in a conditional statement, such as an if, this value is automatically coerced into either true or false to avoid unexpected behavior.
Any value that is considered true when evaluated in a boolean context is called truthy, and includes:
true- non-empty strings (e.g., "hello", "0", "false")
- non-zero numbers (e.g.,
1,-2.5) - arrays (even empty)
- objects (even empty)
- functions
On the other hand, any value that is considered false when evaluated in a boolean context is called falsy, and includes:
false0nullundefinedNaN- empty strings (e.g., "")