Closure function
var test = 1; (function(test){ setTimeout(function() { console.log('closure test is '+test);}, 1000); })(test); test = 2; console.log('test is '+test )