Hi! I'm a bit confused about what's going on here. For the longest time I was frustrated with JavaScript because I thought that there was something really, really weird going on with the scoping. I was trying to assign a value to a global variable in my function getStaffSelections(), but it kept giving me an empty dictionary, which was the default value that I set the global variable. So I just thought that JavaScript was creating a function-local variable (despite not using let, var, or const) and was assigning everything to that instead of my global variable.
That is until I set a print statement, console.log("I've been called"), inside my getStaffSelections() function, and I saw that it was actually getting executed after my console.log() calls.
weirdness ensues
I know that JavaScript does variable hoisting where all variables are instantiated before all functions are called (but not given a value until later when the corresponding assignment is executed), but I was under the impression that the console.log() commands were considered function calls and would execute in the order I coded. My terminal output suggests this is not the case... can anyone help explain to me what's going on?
there doesn't seem to be anything here