var tmp=0; setTimeout(function (){ tmp=10; test(tmp); },1000); alert(tmp); function test(N) { alert(N); };