立即执行函数是表达式,只在括号内可见。
例一 括号内可见
var times = 0; (function hello(){ console.log('hello~'); ++times<2&&hello(); })();
例二 括号外不可见
(function hello(){ console.log('~hello'); }); console.log(hello);
例一 括号内可见
var times = 0; (function hello(){ console.log('hello~'); ++times<2&&hello(); })();
例二 括号外不可见
(function hello(){ console.log('~hello'); }); console.log(hello);