我甚至不知道從哪裏開始搜索這個問題的答案,我以前沒有看到過這樣的語法!速記Javascript變量語法
function (_d) {
this.xiSWFPath = !_d ? "expressinstall.swf" : _d;
this.setAttribute("useExpressInstall", true);
}
這是否等同於
this.xiSWFPath = if not (_d) [declared true, else false] then expressinstall.swf else _d
我明白這是一個初學者的問題! 我可以在哪裏學習更多關於這種語法的知識?
這是速記符號。它存在於大多數基於c的語法語言中 – TGH
它被稱爲三元表達式。這是一個速記if/else。 '(x)?(y):(z);'相當於'if(x){(y); } else {(z); }' – joequincy
也被稱爲「if-then-else」語句,(if)?那麼:else – skyline3000