var a = 10;
sayHi();
function sayHi() {
var a = 20;
alert(a);
}
alert(a);

20 10

var a = 10;
sayHi();
function sayHi() {
a = 20;
alert(a);
}
alert(a);

20 20

var a = 10;
sayHi();
function sayHi()
{
a = a + 10;
alert(a);
return a;
}
alert(a);
alert(sayHi()+10);

20 20 30 40

var a = 10;
sayHi();
function sayHi()
{
var a = a + 10;
alert(a);
return a;
}
alert(a);
alert(sayHi()+10);

NaN , 10 , NaN, NaN