No "var" before "text ="? Declaring "text"


#1

There is no "var" before "text" when this string is first used. Can someone explain why?

https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/1?curriculum_id=506324b3a7dffd00020bf661

text = "Blah blah blah blah blah blah Eric \
blah blah blah Eric blah blah Eric blah blah \
blah blah blah blah blah Eric";

#2

It doesn't matter since this variable is in global scope. var is a scoping tool.


#3

Thank you!, very minimalist compared to C/C++, Java, etc...


#4

A late supplement...

We need to respect the global scope, so much so that we protect it. That is why functions are so invaluable. Not only do we protect our own variables, we also protect the global namespace from being populated with garbage that is never collected and variables that could possibly collide with other programs present in the same namespace (plug-ins and libraries and other script). With everything populating the same space, collisions will happen. It's up to us to prevent that. Protect the global scope.