<script type="text/javascript">
var number = "10";
(function(){
alert(number);
alert(eval('number=22'));
})();
var func = function() {
alert (new Function( 'return (' + number + ')' )());
}
func(); // prints 22.
</script>
It first alerts 10
, then alerts 22
then why is it alerting 22 again instead of 10
. Does eval function overrides my variable in global scope.