【发布时间】:2013-11-01 08:08:31
【问题描述】:
我想知道这两者有何不同?
var hello = foo?foo:bar;
对
var hello = foo || bar;
你能解释一下吗?和一些案例?还是两者都一样?
PS : foo/bar 应该都像 string / int / obj / boolean...
【问题讨论】:
-
所有可能,布尔和.. 字符串.. int.. obj.. @JonathonReinhart
标签: javascript if-statement shorthand shorthand-if