A Tricky JavaScript Interview Question Asked by Google and Amazon
Daniel Borowski
11.4K44

Actually, this might not be the right answer after all, because the const arr declaration isn’t explicitly said to be in a statement block.

If it was (function() {

const arr = [10, 12, 15, 21];

// …

})();

Then, yes, absolutely, undefined four times. If this code snippet is outside of a statement block, then I believe it’s like a var declaration, except you can’t replace arr.