請看下面的代碼:爲什麼這個返回的函數被調用時沒有對其值進行任何操作?
function doNotCallMe(){
alert("Otherwise the world will be destroyed!");
}
function getNotCallable(){
return new function() {
alert("Attention!");
doNotCallMe();
};
}
var not_callable = getNotCallable();
瀏覽器顯示警報,它不應該。爲什麼?怎麼修?
你可以從'return new function(){'中移除'new'。 –
你在說什麼警報? –
@ChinmayeeG:兩者。 – Amadan