in compiled languages it is a compile time error. So you don't run through 1/2 of your application before you run into it. Instead it shows up as soon as you run make/gcc/g++/etc.
E.g. if you use JSHint, you'd get:
"Expected a conditional expression and instead saw an assignment."
Nowadays, there usually isn't any benefit in using yoda conditions.
var test = [
"firstitem"
, "seconditem"
//, "thriditem_commented_out"
//, "fourthitem_should_also_be_commented_out"
]
Otherwise you have to do this: var test = [
"firstitem",
"seconditem"//,
//"thriditem",
//"fourthitem"
]
It's just a lot more cognitive overhead to not put the comma first.if (user.isAuthenticated) doSomething()
vs
doSomething() if (user.isAuthenticated)
the first is less readable perhaps but I think it's more useful for a programmer. To each their own! Maybe some day I'll be convinced otherwise, I like it better for asserts too:
assert(200 = res.statusCode) assert('application/json' == res.headers['content-type'])
assert(res.headers['content-type'] == 'application/json')
looks weird to me now but maybe I'm just used to it