Actual production code:

function isEmpty(val) {
return typeof val === 'undefined'
|| val === undefined
|| !(val !== undefined);

I'm starting to think the "infinite monkeys" metaphor is not a metaphor...

  • 0
    ...double negatives...why....
  • 5
    to be double sure, of course!
  • 0
    @DavidINC is the accepted way to cast to bool in javascript. What an horrible language.
  • 1
    @edwrodrig my mind is blown

    JavaScript is even worse than I thought
  • 0
    It's not as bad as its reputation.

    !(a != b) is a valid statement in pretty much every programming language.
    You can also test (a > 5 && a > 0).

    It's just flawed logic resulting in bad code 😜
Your Job Suck?
Get a Better Job
Add Comment