Hello everyone my question is do vars and functions get stored in a block where they inside the block ?
consider the following code
function myFunction() {
{
var a = 5;
function sayA() {
}
}
}
So again will function sayA
and var a
get stored in the block variable environment or the function variable environment?
I also made a picture to help you understand what I exactly mean
you may ask yourself why i put in the picture sayA
and a
variable inside myFunction because var
and sayA
are function scoped so myFunction
will have a reference to the memory address of sayA
and a
but sayA
and a
variable are really stored in the memory space of Block 1 right ?
and because they considered a function scoped
the myFunction execution context have a reference to their memory address
right ?