@aredridel
Thought of the moment: I never use === in javascript. I find that every time I need it, I've made a boneheaded design flaw elsewhere.
@chris__martin
@aredridel === is a promise to the maintainer who comes after you that you knew what you were doing.
@aredridel
@chris__martin Heh. For me it's a signal that they didn't know what they were operating on.
Hm. I think in that case, I'd prefer the
i > 0case, which seems contrary to my preference for==, but let me explain.===really hints to me that there's three cases. "Exactly what I meant" and a yet-to-be-differentiated "something else of that type" and "uh what?" -- especially when it's used following a typeof check (which I see a lot in that style of code)I'd rather the loose type
==, "value I was looking for, or close enough to not care" and "not", or "greater than zero" or "not". They're both conditions that imply a certain closure over the input space.I also tend to look for meaning in code -- the
i != 0case really says 'not zero' not 'positive number'. If I wanted to clarify "number", I'd writeNumber(i) > 0, nottypeof i == 'number' && i > 0. It's got a lower npath complexity and a clearer meaning.