loading...

re: A tricky JavaScript interview question asked by Google VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I agree with you on the interview process. On the other hand, this question is great to start a conversation on why old-school JavaScript is bad -...
 

Agree with you. At first I thought the same thing everyone else did. It would print out the value. But as soon as I saw the index 4, I knew exactly what was happening.

This is the sort of thing you usually don't spot while coding but once you see it happening (usually in test run), is trivial to debug and fix. For one, using let and const over var produces more sensible and predictable results.

code of conduct - report abuse