function constUseful () { var guarded = 1; (function loop (orgGuarded) { setTimeout(function () { if (guarded !== orgGuarded) { throw 'guarded reassigned!'; } loop(orgGuarded); }, 0); })(guarded); guarded = 2; } constUseful();