function a(delay){
this.randomVal = Math.random();
window.setTimeout(function(){
document.write('function a called - '+this.randomVal+' '+delay+'<br/>');
}, delay)
}
a(2000);
a(5000);
a(1000);
結果輸出:爲什麼每個單獨調用的函數更新中沒有值?
function a called - 0.7679888338316232 1000
function a called - 0.7679888338316232 2000
function a called - 0.7679888338316232 5000
我敢肯定,這是一個經典的問題,但爲什麼沒有內部功能randomVal「A」更新每次調用的時候..?