Hy there.
Let's look at it this way, when you declare a variable named 'a=1' (the variable you declared is a global one) , a memory house is assigned to a variable that has this value: 1
and after you declare the function:
function a() {}
there is no memory house in type of variable for 'a' anymore and the a is a function.
but, the memory house for 'a' doesn't cleared and it stills available and it is like the a function called once and returned the last assigned value!
so, when you write this codes:
a = 1;
function a() {}
it is just like:
function a(){
return 1;
}
console.log(a());
this problem is like because of a Incomplete nature(i mean memory house type) change.