What does the logical OR `||` operator return in JavaScript?

JavaScript Associate Easy

JavaScript Associate — Easy

What does the logical OR `||` operator return in JavaScript?

Key points

  • The `||` operator returns the first truthy operand
  • If none of the operands are truthy, it returns the last operand
  • It does not always return a boolean true or false
  • It does not require both operands to be truthy to return true

Ready to go further?

Related questions