Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
Can you explain why logical && in JavaScript returns the last operand in a statement if all operands are true, as opposed to returning boolean true

I am reading a really nice blog on logical and (&&) in javascript. javascript-and-or-logical-operators/

How logical and works

Starting from left and moving to the right, return the first operand that is falsy. If no falsy operand was found, return the latest operand.

his example

FALSY:

3 && 1 && 0 && 10; // => 0

I see that it returns 0, based on his explanation above. But why is that? Why isn't false returned instead. I realize that 0 is "falsy", so I would believe that the statement would now evaluate to boolean false? But I am not right, can you explain why?

he also presents this example

TRUTHY

true && 1 && { name: 'John' } => { name: 'John' }

I am confused again. Why does this statement return { name: 'John' } instead of returning true?

Thank you kind people for your patience in answering my question.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!