在我的情况下,函数无法执行

use*_*928 1 javascript jquery

function say667() {
    // Local variable that ends up within closure
    var num = 666;
    var sayAlert = function() { alert(num); }
    num++;
    return sayAlert;
}

 say667();
Run Code Online (Sandbox Code Playgroud)

怎么了?我在jsfiddle中尝试了这个代码,警告没有弹出..

Sha*_*ard 7

你只需返回函数参考.()如果要执行它,则需要使用它来调用它:

say667()();
Run Code Online (Sandbox Code Playgroud)

现场测试案例.