361
技术社区[云栖]
自执行函数的优点
保护内部变量不受污染
(function() {
function init() {
console.log('init');
handleA();
}
function handleA() {
console.log('handleA');
handleB();
}
function handleB() {
console.log('handleB');
}
window.init = init;
}())
执行 init();
init
handleA
handleB
undefined
最后更新:2017-11-08 20:35:32