ELI5: Explain Like I'm 5

Global variable

A global variable is like a toy that all the kids in the playground can play with. It's something that you can use anywhere in the playground without having to go get a new toy.

In a computer program, a global variable is a special kind of variable that you can use in any part of the program. It is not limited to a specific part of the program like a normal variable would be.

So, for example, if you have a toy box in one corner of the playground, you can only use the toys in that box when you're playing in that corner of the playground. But if you have a toy that everyone can play with no matter where they are on the playground, that's like a global variable.

The reason we use global variables is because sometimes we need to keep track of something that's important for the whole program, not just for one small part of it. Just like the toy that everybody can play with, a global variable is something that everybody in the program can use if they need it.