Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
first is way more intuitive.. "have this, but update it if condition matches" readability wins
-
The first. Why are you redeclaring foo though? You already said "var foo" but then you do it again in the conditional block. Wouldn't it just be "foo" in there?
-
lewdogg9959yIs this a trick question. Obviously, make sure it exists first, and assume the worst.
Do you prefer?
var foo = true;
if (some condition){
var foo = false;
}
Or
if (some condition){
var foo = false;
}
else{
var foo = true;
}
undefined