當lsEstimator
是具有2個元素的陣列,該函數返回true
:這兩個JS函數爲什麼不同?
function got_estimators() {
var retval =
(typeof lsEstimator != 'undefined' &&
lsEstimator != null &&
lsEstimator.length > 0);
return retval;
}
但此函數不(它返回undefined
,我想,在瀏覽器和FF):
function got_estimators() {
return
(typeof lsEstimator != 'undefined' &&
lsEstimator != null &&
lsEstimator.length > 0);
}
爲什麼?
@FelixKling,因爲它是正確的一個,你應該寫一個答案。 – mpm 2013-03-12 12:49:30
哇。 1分鐘很不錯。那麼第二個函數實際上做了什麼? – EML 2013-03-12 12:50:01
自動分號插入是所有邪惡的根源:-( – Bergi 2013-03-12 12:51:58