且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

函数声明不应放在块中。使用函数表达式或将语句移动到外部函数的顶部

更新时间:2023-11-09 09:02:34

你不应该在if中创建函数。你做得好多了:

You should not be creating function inside if block. You are much better off doing:

var e = function(){};

if(typeof console === "object" && typeof console.error === "function"){
    e = function (msg){ ... };
}