Interview practice question
An accidental global variable causes strange bugs
Frontend Engineering · JavaScript Core · Intermediate
Values seem to leak between unrelated parts of an old script. You suspect an accidental global variable. How do you find and prevent it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Assignment without declaration creates global (sloppy mode).
- Strict mode throws instead.
- Linting (no-undef).
- Modules scope by default.
- Search for undeclared assignments.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.