I have been programming for 5 years but I just started wondering something. In this code example, I return a value from a function and store it a variable. In what order does this happen? Does it matter whether the language is interpreted or compiled?
function foo() {
return "junk";
}
var bar = foo();
Now I know bar = "junk". In what order does this take place? I know when a function is called it returns the control back to the function invoking it and the program resumes where it left off, so does that mean it returns back to 'var bar =' ?
And in a dynamically typed language, how is bar initially created? Is it created on the heap?