JavaScript
One line if statements

by Lipis

if (condition) {
  doSomething();
}

if (condition) doSomething();

Good Lord Variant B ...

Tommaso Piazza

condition ? doSomething() : dontDoSomething();

😎

Chris

@Chris: Yup, ((true === true) ? true : false) :D

Sabri

I do Option B for debugger statements. Which way is stage left?

tasos-bitsios

Explicit is better than implicit. Some browsers do not support one-line if operations.

Foxatron

condition && doSomething();

B)

Rama Jakaria

Sign in to comment!