You don't need a function. The ||
operator is usually used:
Ext.Msg.show({ title: js_shutdown || 'Shutdown', //...
You can see ||
as:
someValue || defaultValue
For strings, defaultValue
is used if someValue === ""
.
If the variable is not defined at all, you'll need to inline the typeof x === "undefined"
check, because you cannot pass the variable to a function (that's a ReferenceError
).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…