一个js文件中,包含多个函数,应该只有一个调用,例如:javascript
var fun = function(x) { if (x < 1) { return x; } else { return -x; } } function ensure(condition, message) { if (!condition) { console.log(message) } } function testFun() { ensure(fun(1) === -1, 'fun 1 错误'); ensure(fun(2) === -2, 'fun 2 错误'); ensure(fun(0) === 0, 'fun 0 错误'); } fuction __main() { testFun(); } // 应该只有这一个调用 // 程序只有这一个入口,经过这个调用开始其余代码的运行 __main();