当我将闭包中的js逻辑作为单个js文件编写时,一切工作正常,例如:
(function(win){
//main logic here
win.expose1 = ....
win.expose2 = ....
})(window)
但是,当我尝试在同一个js文件中的闭包之前插入替代日志记录功能时,
window.Glog = function(msg){
console.log(msg)
}
// this was added before the main closure.
(function(win){
//the former closure that contains the main javascript logic;
})(window)
它抱怨有一个TypeError:
Uncaught TypeError: (intermediate value)(...) is not a function
我做错什么了?