A Tricky JavaScript Interview Question Asked by Google and Amazon
Daniel Borowski
6.2K30

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.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.