2012-09-01 88 views

回答

7

使用typeof將與未聲明/未定義對象傳遞。

if (typeof Prototype !== "undefined") { 
    // ... 
} 
0

我相信這是稍微乾淨:

var Prototype = window.Prototype; 
if(Prototype) { //Prototype is loaded } 
+0

檢查truthy VS檢查undefined是不同 –

+0

是否有解釋說,差別有關係嗎?我認爲至少在這種情況下解決方案是相同的。 – Memos