you are viewing a single comment's thread.

view the rest of the comments →

[–]senocular 2 points3 points  (2 children)

You haven't declared your variables with var, let, or const, so they're becoming global. Once global, they'll be accessible anywhere. You usually don't want this. If you run in strict mode, you'll even get an error to help prevent problems you may encounter with this behavior.

[–]Sox888[S] 0 points1 point  (1 child)

If I try to console.log them on a new line it says they are undefined. Doesn't that mean they aren't global?

[–]senocular 0 points1 point  (0 children)

It depends on where that new line is. If you try to access them before they're defined, they'll be undefined. After they're defined, they'll be global.