可能重複:
Javascript Shorthand - What Does the '||' Operator Mean When Used in an Assignment?這段代碼是什麼意思?
var variable = obj1 || obj2;
莫非這?
var variable;
if (obj1)
{
variable = obj1;
}
else if (obj2)
{
variable = obj2:
}
它被認爲是不好的做法?
可能重複[Javascript速記 - 什麼是'||'運算符意味着什麼時候在作業?](http://stackoverflow.com/questions/4511301/javascript-shorthand-what-does-the-operator-mean-when-used-in-an-assignme)和[JavaScript | |操作者(http://stackoverflow.com/questions/1378619/javascript-operator)。 – 2012-02-23 17:06:24