请看下面的代码:为什么这个返回的函数被调用时没有对其值进行任何操作?
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