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