57

function getTrue() {
return true;
}

Wut? You serious?

Comments
  • 10
    Just in case the value of true changes?
  • 11
    Well, you can't trust anything these days.
  • 3
    It's for minification.
  • 1
    Hmmph. Stylistically, it reminds me of a lot of Java code I've seen. Getter functions for every property!
  • 7
    I wrote a quick unit test for that:

    expect(getTrue()).to.equal(true);

    Thank me later.
  • 0
    That's valid and useful when you're using higher-order functions. E.g. You're passing in a function that's expected to return a bool, but you want to always return true.
  • 0
    It implies that there might be some optimisation possible, but it's certainly not mad or wrong.
Add Comment