Frage im Vorstellungsgespräch bei Susco

They showed me a block of JavaScript code in which they declared a function with a function inside the outer function with a statement inside that function that modified a value Then outside the function set a initial value then modified the value then called then called the function that modified the value. Then asked what the value was at each point.

Antwort im Vorstellungsgespräch

Anonym

27. Aug. 2016

I answered incorrectly because my first impression was that nothing would happen when the function was called because there was no instance of the outer function available in order to call the inner function. But then I thought to myself That's crazy who would write a function with only one function inside of it because you have to twice as much work to call the inner function. So I fell for his trick and used the inner function to modify the value. I thought I must have missed something. I did.