var defaultname = "John";
var name = "rayn";
function doit() {
if(!name){
var name = defaultname;
}
return name;
}
var ourname = doit();
console.log(ourname); //John
// because name inside function will have more priority over outside name variable.
// And, this inside name variable will be declared in memory as undefined due to hoisting.
var a = 10;
{
var a = -10;
}
let b = a;
{
let b = -20;
}
console.log(b)
// program to display value
a = 5;
console.log(a);
var a; // 5