Global scope in JS

I’m a little bit confused about the var declaration for variables.

In the second paragraph, it says that variables with the var keyword are automatically created in the global scope.

But in the next paragraph, it asks us to use var to declare a global variable.

It says without it, not with the var keyword, that variables are automatically created in the global scope. It is not recommended also because you can overwrite without knowing some Global variable you’ve already created with var keyword, ending up with a reassignment.
Example:

foo='replaced';
var foo='replace me';

1 Like

Ohhhhh! Thank you. I must have been crossed eyed by that hours. Silly me.