Shorthand if..else..?

Is this a shorthand if else statement?

var _docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;

If not, what is this variable saying?

variable = (condition) ? trueValue : falseValue;

See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Operators:Special_Operators:Conditional_Operator

In longhand it is:


if (condition) {
    variable = trueValue;
} else {
    variable = falseValue;
}

It’s called the ternary operator, and that’s exactly what it is.