【发布时间】:2014-03-24 11:08:01
【问题描述】:
以下内容的 JS 简写是什么:
if (typeof bfMax !== 'undefined') {
options.max = bfMax;
}
【问题讨论】:
标签: javascript
以下内容的 JS 简写是什么:
if (typeof bfMax !== 'undefined') {
options.max = bfMax;
}
【问题讨论】:
标签: javascript
有条件地赋值的简洁、可读、可维护、简写是:
if (typeof bfMax !== 'undefined') {
options.max = bfMax;
}
您似乎已经在使用它了。
如果您想缩小脚本以使其更短、可读性更低且不可维护,您可以使用:
typeof bfMax!=='undefined'&&(options.max=bfMax)
当然,你会想换掉你的变量名来缩短内容:
typeof b!=='undefined'&&(o.max=b)
【讨论】: