1
function f() {
    var b = "b";
    return function() {
        alert(b);
        return b;
    };
}
var a = function f();
    alert(a);
​

我尝试运行此代码,但出现我不理解的错误。

Error:
Problem at line 8 character 21: Expected '{' and instead saw ';'.
var a = function f();

Problem at line 8 character 21: Unnecessary semicolon.
var a = function f();

Problem at line 8 character 22: Missing semicolon.
var a = function f();

Implied global: alert 4,9

这段代码有什么问题我想从全局范围内提醒privete var。我应该改变什么?很多谢谢。​</p>

4

1 回答 1

4
 var a = function f();

这没有任何意义。
如果您尝试调用该函数,只需编写f().

于 2012-09-16T13:23:50.940 回答