Skip to content

Instantly share code, notes, and snippets.

@chrisjpowers
Created September 18, 2012 15:10
Show Gist options
  • Save chrisjpowers/3743662 to your computer and use it in GitHub Desktop.
Save chrisjpowers/3743662 to your computer and use it in GitHub Desktop.
JavaScript Syntax Question
// Do you prefer...
if (a) {
doA();
} else if (b) {
doB();
} else {
doC();
}
// or...
if (a) {
doA();
}
else if (b) {
doB();
}
else {
doC();
}
// Similarly, this...
try {
doSomething();
} catch (e) {
console.log(e);
}
// or...
try {
doSomething();
}
catch (e) {
console.log(e);
}
@bf4
Copy link

bf4 commented Sep 19, 2012

the fist captures the idea of a logical block better, which, I think, is more valuable than any potential lost clarity by condensing it. (also, as mentioned, saves screen real estate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment