JavaScript If/Else Shorthand March 18th, 2013
Writing this…
if (index === 2) {
return null
} else {
return value;
}
Is the same as saying…
//return [test condition] ? [return this if true] : [return this if false] return index === 2 ? null : value; OR var myVariable = condition ? this_if_true : that_if_false;