0
使用Chrome的控制檯/調試器:Javascript切換 - 無結果,甚至默認?
在if語句,quickChallengeResponse顯示未定義
而且console.dir(quickChallengeTimer)顯示30
然而,我的網頁上,沒有打印,不即使錯誤 - 並quickChallengeTimer不會更改爲60,因爲它被告知要做的情況下30.
我的錯誤是什麼?謝謝。
var quickChallengeTimer = 30; var quickChallengeQuestion;
var quickChallengeAnswer; var quickChallengeResponse;
function quickChallenge(quickChallengeTimer,
quickChallengeQuestion, quickChallengeAnswer) {
if (typeof quickChallengeResponse == undefined) {
switch (quickChallengeTimer) {
case 30:
quickChallengeTimer = "60";
quickChallengeResponse = null;
console.write("now60");
break;
case 60:
quickChallengeTimer = "120";
quickChallengeResponse = null;
console.write("now120");
break;
default:
console.write("Error");
break;
}
}
console.dir(quickChallengeTimer);
}
quickChallenge(quickChallengeTimer);
的結果['typeof'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof)總是一個字符串。該比較應該反對''undefined''(帶引號)而不是[全局變量](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)。 – 2014-10-11 23:41:59
喬納森,我剛剛添加了'標記,仍然是:沒有顯示任何內容。 – icor103 2014-10-11 23:43:45
一個大問題是,沒有console.write()這樣的東西... ... – dandavis 2014-10-11 23:48:28